summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGUI/WindowServerConnection.cpp11
-rw-r--r--Userland/Libraries/LibGUI/WindowServerConnection.h3
-rw-r--r--Userland/Libraries/LibGfx/FontDatabase.cpp51
-rw-r--r--Userland/Libraries/LibGfx/FontDatabase.h5
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.cpp4
5 files changed, 61 insertions, 13 deletions
diff --git a/Userland/Libraries/LibGUI/WindowServerConnection.cpp b/Userland/Libraries/LibGUI/WindowServerConnection.cpp
index d51d57d1e3..ac9ff33b5a 100644
--- a/Userland/Libraries/LibGUI/WindowServerConnection.cpp
+++ b/Userland/Libraries/LibGUI/WindowServerConnection.cpp
@@ -21,6 +21,7 @@
#include <LibGUI/Window.h>
#include <LibGUI/WindowServerConnection.h>
#include <LibGfx/Bitmap.h>
+#include <LibGfx/FontDatabase.h>
#include <LibGfx/Palette.h>
#include <LibGfx/SystemTheme.h>
@@ -47,9 +48,11 @@ void WindowServerConnection::handshake()
auto message = wait_for_specific_message<Messages::WindowClient::FastGreet>();
set_system_theme_from_anonymous_buffer(message->theme_buffer());
Desktop::the().did_receive_screen_rect({}, message->screen_rect());
+ Gfx::FontDatabase::set_default_font_query(message->default_font_query());
+ Gfx::FontDatabase::set_fixed_width_font_query(message->fixed_width_font_query());
}
-void WindowServerConnection::fast_greet(Gfx::IntRect const&, Core::AnonymousBuffer const&)
+void WindowServerConnection::fast_greet(Gfx::IntRect const&, Core::AnonymousBuffer const&, String const&, String const&)
{
// NOTE: This message is handled in handshake().
}
@@ -63,6 +66,12 @@ void WindowServerConnection::update_system_theme(Core::AnonymousBuffer const& th
});
}
+void WindowServerConnection::update_system_fonts(const String& default_font_query, const String& fixed_width_font_query)
+{
+ Gfx::FontDatabase::set_default_font_query(default_font_query);
+ Gfx::FontDatabase::set_fixed_width_font_query(fixed_width_font_query);
+}
+
void WindowServerConnection::paint(i32 window_id, Gfx::IntSize const& window_size, Vector<Gfx::IntRect> const& rects)
{
if (auto* window = Window::from_window_id(window_id))
diff --git a/Userland/Libraries/LibGUI/WindowServerConnection.h b/Userland/Libraries/LibGUI/WindowServerConnection.h
index 38b2a3db9f..6c7e4d2d5c 100644
--- a/Userland/Libraries/LibGUI/WindowServerConnection.h
+++ b/Userland/Libraries/LibGUI/WindowServerConnection.h
@@ -27,7 +27,7 @@ public:
static WindowServerConnection& the();
private:
- virtual void fast_greet(Gfx::IntRect const&, Core::AnonymousBuffer const&) override;
+ virtual void fast_greet(Gfx::IntRect const&, Core::AnonymousBuffer const&, String const&, String const&) override;
virtual void paint(i32, Gfx::IntSize const&, Vector<Gfx::IntRect> const&) override;
virtual void mouse_move(i32, Gfx::IntPoint const&, u32, u32, u32, i32, bool, Vector<String> const&) override;
virtual void mouse_down(i32, Gfx::IntPoint const&, u32, u32, u32, i32) override;
@@ -54,6 +54,7 @@ private:
virtual void drag_accepted() override;
virtual void drag_cancelled() override;
virtual void update_system_theme(Core::AnonymousBuffer const&) override;
+ virtual void update_system_fonts(String const&, String const&) override;
virtual void window_state_changed(i32, bool, bool) override;
virtual void display_link_notification() override;
virtual void ping() override;
diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp
index d059de5f94..76d4517b80 100644
--- a/Userland/Libraries/LibGfx/FontDatabase.cpp
+++ b/Userland/Libraries/LibGfx/FontDatabase.cpp
@@ -24,24 +24,55 @@ FontDatabase& FontDatabase::the()
return *s_the;
}
+static RefPtr<Font> s_default_font;
+static String s_default_font_query;
+static RefPtr<Font> s_fixed_width_font;
+static String s_fixed_width_font_query;
+
+void FontDatabase::set_default_font_query(String query)
+{
+ if (s_default_font_query == query)
+ return;
+ s_default_font_query = move(query);
+ s_default_font = nullptr;
+}
+
+String FontDatabase::default_font_query()
+{
+ return s_default_font_query;
+}
+
Font& FontDatabase::default_font()
{
- static Font* font;
- if (!font) {
- font = FontDatabase::the().get_by_name("Katica 10 400");
- VERIFY(font);
+ if (!s_default_font) {
+ VERIFY(!s_default_font_query.is_empty());
+ s_default_font = FontDatabase::the().get_by_name(s_default_font_query);
+ VERIFY(s_default_font);
}
- return *font;
+ return *s_default_font;
+}
+
+void FontDatabase::set_fixed_width_font_query(String query)
+{
+ if (s_fixed_width_font_query == query)
+ return;
+ s_fixed_width_font_query = move(query);
+ s_fixed_width_font = nullptr;
+}
+
+String FontDatabase::fixed_width_font_query()
+{
+ return s_fixed_width_font_query;
}
Font& FontDatabase::default_fixed_width_font()
{
- static Font* font;
- if (!font) {
- font = FontDatabase::the().get_by_name("Csilla 10 400");
- VERIFY(font);
+ if (!s_fixed_width_font) {
+ VERIFY(!s_fixed_width_font_query.is_empty());
+ s_fixed_width_font = FontDatabase::the().get_by_name(s_fixed_width_font_query);
+ VERIFY(s_fixed_width_font);
}
- return *font;
+ return *s_fixed_width_font;
}
struct FontDatabase::Private {
diff --git a/Userland/Libraries/LibGfx/FontDatabase.h b/Userland/Libraries/LibGfx/FontDatabase.h
index 7ad5f8b691..4f75ee5c88 100644
--- a/Userland/Libraries/LibGfx/FontDatabase.h
+++ b/Userland/Libraries/LibGfx/FontDatabase.h
@@ -37,6 +37,11 @@ public:
static Font& default_font();
static Font& default_fixed_width_font();
+ static String default_font_query();
+ static String fixed_width_font_query();
+ static void set_default_font_query(String);
+ static void set_fixed_width_font_query(String);
+
RefPtr<Gfx::Font> get(const String& family, unsigned size, unsigned weight);
RefPtr<Gfx::Font> get(const String& family, const String& variant, unsigned size);
RefPtr<Gfx::Font> get_by_name(const StringView&);
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
index d3c339811a..a3a76b7266 100644
--- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
+++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -15,6 +15,7 @@
#include <LibGUI/Painter.h>
#include <LibGUI/Scrollbar.h>
#include <LibGUI/Window.h>
+#include <LibGfx/FontDatabase.h>
#include <LibGfx/Palette.h>
#include <LibGfx/SystemTheme.h>
@@ -69,6 +70,7 @@ void OutOfProcessWebView::create_client()
};
client().async_update_system_theme(Gfx::current_system_theme_buffer());
+ client().async_update_system_fonts(Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query());
client().async_update_screen_rect(GUI::Desktop::the().rect());
}