mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Support multiple emoji/symbol fonts
This commit is contained in:
parent
01ad180182
commit
abcc5bc16d
Notes:
github-actions[bot]
2025-11-03 09:57:33 +00:00
Author: https://github.com/socram8888
Commit: abcc5bc16d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6665
Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 20 additions and 18 deletions
|
|
@ -1927,8 +1927,11 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||
font_list->add(*default_font);
|
||||
}
|
||||
|
||||
if (auto emoji_font = Platform::FontPlugin::the().default_emoji_font(font_size_in_pt); emoji_font) {
|
||||
font_list->add(*emoji_font);
|
||||
// Add emoji and symbol fonts
|
||||
for (auto font_name : Platform::FontPlugin::the().symbol_font_names()) {
|
||||
if (auto other_font_list = find_font(font_name)) {
|
||||
font_list->extend(*other_font_list);
|
||||
}
|
||||
}
|
||||
|
||||
// The default font is already included in the font list, but we explicitly set it
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ public:
|
|||
|
||||
virtual RefPtr<Gfx::Font> default_font(float point_size) = 0;
|
||||
virtual Gfx::Font& default_fixed_width_font() = 0;
|
||||
virtual RefPtr<Gfx::Font> default_emoji_font(float point_size) = 0;
|
||||
|
||||
virtual FlyString generic_font_name(GenericFont) = 0;
|
||||
virtual Vector<FlyString> symbol_font_names() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,16 @@ FontPlugin::FontPlugin(bool is_layout_test_mode, Gfx::SystemFontProvider* font_p
|
|||
auto default_fixed_width_font_name = generic_font_name(Web::Platform::GenericFont::UiMonospace);
|
||||
m_default_fixed_width_font = Gfx::FontDatabase::the().get(default_fixed_width_font_name, 12.0, 400, Gfx::FontWidth::Normal, 0);
|
||||
VERIFY(m_default_fixed_width_font);
|
||||
|
||||
if (is_layout_test_mode) {
|
||||
m_symbol_font_names = { "Noto Emoji"_fly_string };
|
||||
} else {
|
||||
#ifdef AK_OS_MACOS
|
||||
m_symbol_font_names = { "Apple Color Emoji"_fly_string, "Apple Symbols"_fly_string };
|
||||
#else
|
||||
m_symbol_font_names = { "Noto Color Emoji"_fly_string, "Noto Sans Symbols"_fly_string };
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
FontPlugin::~FontPlugin() = default;
|
||||
|
|
@ -54,21 +64,9 @@ Gfx::Font& FontPlugin::default_fixed_width_font()
|
|||
return *m_default_fixed_width_font;
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Font> FontPlugin::default_emoji_font(float point_size)
|
||||
Vector<FlyString> FontPlugin::symbol_font_names()
|
||||
{
|
||||
FlyString default_emoji_font_name;
|
||||
|
||||
if (m_is_layout_test_mode) {
|
||||
default_emoji_font_name = "Noto Emoji"_fly_string;
|
||||
} else {
|
||||
#ifdef AK_OS_MACOS
|
||||
default_emoji_font_name = "Apple Color Emoji"_fly_string;
|
||||
#else
|
||||
default_emoji_font_name = "Noto Color Emoji"_fly_string;
|
||||
#endif
|
||||
}
|
||||
|
||||
return Gfx::FontDatabase::the().get(default_emoji_font_name, point_size, 400, Gfx::FontWidth::Normal, 0);
|
||||
return m_symbol_font_names;
|
||||
}
|
||||
|
||||
#ifdef USE_FONTCONFIG
|
||||
|
|
|
|||
|
|
@ -21,13 +21,14 @@ public:
|
|||
|
||||
virtual RefPtr<Gfx::Font> default_font(float point_size) override;
|
||||
virtual Gfx::Font& default_fixed_width_font() override;
|
||||
virtual RefPtr<Gfx::Font> default_emoji_font(float point_size) override;
|
||||
virtual FlyString generic_font_name(Web::Platform::GenericFont) override;
|
||||
virtual Vector<FlyString> symbol_font_names() override;
|
||||
|
||||
void update_generic_fonts();
|
||||
|
||||
private:
|
||||
Vector<FlyString> m_generic_font_names;
|
||||
Vector<FlyString> m_symbol_font_names;
|
||||
FlyString m_default_font_name;
|
||||
RefPtr<Gfx::Font> m_default_fixed_width_font;
|
||||
bool m_is_layout_test_mode { false };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue