mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Include system emoji font in a font cascade list
Adds emoji rendering support on macOS and linux (if it has "Noto Color Emoji" font).
This commit is contained in:
parent
c88e76add7
commit
22b8380e37
Notes:
github-actions[bot]
2024-09-06 12:31:40 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/22b8380e379 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1297 Reviewed-by: https://github.com/trflynn89
4 changed files with 17 additions and 0 deletions
|
@ -61,6 +61,17 @@ Gfx::Font& FontPlugin::default_fixed_width_font()
|
|||
return *m_default_fixed_width_font;
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Font> FontPlugin::default_emoji_font(float point_size)
|
||||
{
|
||||
#ifdef AK_OS_MACOS
|
||||
auto default_emoji_font_name = "Apple Color Emoji"_fly_string;
|
||||
#else
|
||||
auto 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);
|
||||
}
|
||||
|
||||
#ifdef USE_FONTCONFIG
|
||||
static Optional<String> query_fontconfig_for_generic_family(Web::Platform::GenericFont generic_font)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ public:
|
|||
|
||||
virtual Gfx::Font& default_font() 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;
|
||||
|
||||
void update_generic_fonts();
|
||||
|
|
|
@ -2325,6 +2325,10 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||
font_list->extend(*other_font_list);
|
||||
}
|
||||
|
||||
if (auto emoji_font = Platform::FontPlugin::the().default_emoji_font(font_size_in_pt); emoji_font) {
|
||||
font_list->add(*emoji_font);
|
||||
}
|
||||
|
||||
auto found_font = StyleProperties::font_fallback(monospace, bold);
|
||||
font_list->set_last_resort_font(found_font->with_size(font_size_in_pt));
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
|
||||
virtual Gfx::Font& default_font() = 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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue