summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-09-17 21:25:15 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2022-12-25 07:58:58 -0700
commit3628eda0db6c5f65f5c0b8698f0f141856f5cf48 (patch)
treea54c6d32a748682bf01be6e6c2f6282e581310c0
parentc230264c63104133f1d5e521257558c8b3c67c5f (diff)
downloadserenity-3628eda0db6c5f65f5c0b8698f0f141856f5cf48.zip
Ladybird/FontPluginQt: Implement default font virtuals
-rw-r--r--Ladybird/FontPluginQt.cpp14
-rw-r--r--Ladybird/FontPluginQt.h5
2 files changed, 19 insertions, 0 deletions
diff --git a/Ladybird/FontPluginQt.cpp b/Ladybird/FontPluginQt.cpp
index 811d92af9d..956024d05c 100644
--- a/Ladybird/FontPluginQt.cpp
+++ b/Ladybird/FontPluginQt.cpp
@@ -28,10 +28,24 @@ FontPluginQt::FontPluginQt()
Gfx::FontDatabase::set_fixed_width_font_query("Csilla 10 400 0");
update_generic_fonts();
+
+ auto default_font_name = generic_font_name(Web::Platform::GenericFont::UiSansSerif);
+ m_default_font = Gfx::FontDatabase::the().get(default_font_name, 12.0, 400, 0);
+ VERIFY(m_default_font);
}
FontPluginQt::~FontPluginQt() = default;
+Gfx::Font& FontPluginQt::default_font()
+{
+ return *m_default_font;
+}
+
+Gfx::Font& FontPluginQt::default_fixed_width_font()
+{
+ return *m_default_fixed_width_font;
+}
+
void FontPluginQt::update_generic_fonts()
{
// How we choose which system font to use for each CSS font:
diff --git a/Ladybird/FontPluginQt.h b/Ladybird/FontPluginQt.h
index ef1677b701..94cb011ef2 100644
--- a/Ladybird/FontPluginQt.h
+++ b/Ladybird/FontPluginQt.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/RefPtr.h>
#include <AK/Vector.h>
#include <LibWeb/Platform/FontPlugin.h>
@@ -16,12 +17,16 @@ public:
FontPluginQt();
virtual ~FontPluginQt();
+ virtual Gfx::Font& default_font() override;
+ virtual Gfx::Font& default_fixed_width_font() override;
virtual String generic_font_name(Web::Platform::GenericFont) override;
void update_generic_fonts();
private:
Vector<String> m_generic_font_names;
+ RefPtr<Gfx::Font> m_default_font;
+ RefPtr<Gfx::Font> m_default_fixed_width_font;
};
}