summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-05-21 18:10:23 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-21 20:15:51 +0200
commitbb23e61fbff779f56dd18cf4abd6ae5c0f8d8514 (patch)
tree580ba33767f3124693003dfd8a0e767865327e3e /Userland/Libraries/LibGfx
parent66ad73993468807b8dff5367794acd66ebee1e59 (diff)
downloadserenity-bb23e61fbff779f56dd18cf4abd6ae5c0f8d8514.zip
LibGfx+WindowServer: Have WindowServer broadcast system font settings
Instead of everybody getting their system fonts from Gfx::FontDatabase (where it's all hardcoded), they now get it from WindowServer. These are then plumbed into the usual Gfx::FontDatabase places so that the old default_font() and default_fixed_width_font() APIs keep working.
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r--Userland/Libraries/LibGfx/FontDatabase.cpp51
-rw-r--r--Userland/Libraries/LibGfx/FontDatabase.h5
2 files changed, 46 insertions, 10 deletions
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&);