mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +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:
committed by
Tim Flynn
parent
c88e76add7
commit
22b8380e37
@@ -61,6 +61,17 @@ Gfx::Font& FontPlugin::default_fixed_width_font()
|
|||||||
return *m_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
|
#ifdef USE_FONTCONFIG
|
||||||
static Optional<String> query_fontconfig_for_generic_family(Web::Platform::GenericFont generic_font)
|
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_font() override;
|
||||||
virtual Gfx::Font& default_fixed_width_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;
|
virtual FlyString generic_font_name(Web::Platform::GenericFont) override;
|
||||||
|
|
||||||
void update_generic_fonts();
|
void update_generic_fonts();
|
||||||
|
|||||||
@@ -2325,6 +2325,10 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||||||
font_list->extend(*other_font_list);
|
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);
|
auto found_font = StyleProperties::font_fallback(monospace, bold);
|
||||||
font_list->set_last_resort_font(found_font->with_size(font_size_in_pt));
|
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_font() = 0;
|
||||||
virtual Gfx::Font& default_fixed_width_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;
|
virtual FlyString generic_font_name(GenericFont) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user