Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Libraries/LibWeb/CSS/StyleComputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1931,8 +1931,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
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibWeb/Platform/FontPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class WEB_API FontPlugin {

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;
};

}
26 changes: 12 additions & 14 deletions Libraries/LibWebView/Plugins/FontPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Libraries/LibWebView/Plugins/FontPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ class WEBVIEW_API FontPlugin final : public Web::Platform::FontPlugin {

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 };
Expand Down
Loading