summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-03-04 20:54:25 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-06 10:52:55 +0100
commit552895da60ebb30d81712a7c81718cda6ab73ef6 (patch)
treeef202e2e572e02af286e6ed525c7d7319a460db3 /Userland/Libraries/LibGfx
parent924d23353ef633c7b013afb1d62075df2cf5c9a9 (diff)
downloadserenity-552895da60ebb30d81712a7c81718cda6ab73ef6.zip
LibGfx: Skip old-style emoji lookup for fonts that have color bitmaps
Ultimately, we should find a way to route all emoji access through the font code, but for now, this patch adds a special case for fonts that are known to have embedded color bitmaps so we can test them.
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r--Userland/Libraries/LibGfx/Font/ScaledFont.cpp6
-rw-r--r--Userland/Libraries/LibGfx/Painter.cpp3
2 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGfx/Font/ScaledFont.cpp b/Userland/Libraries/LibGfx/Font/ScaledFont.cpp
index d28b0092c5..ccdc85529e 100644
--- a/Userland/Libraries/LibGfx/Font/ScaledFont.cpp
+++ b/Userland/Libraries/LibGfx/Font/ScaledFont.cpp
@@ -107,8 +107,10 @@ float ScaledFont::glyph_width(u32 code_point) const
template<typename CodePointIterator>
static float glyph_or_emoji_width_impl(ScaledFont const& font, CodePointIterator& it)
{
- if (auto const* emoji = Emoji::emoji_for_code_point_iterator(it))
- return font.pixel_size() * emoji->width() / emoji->height();
+ if (!font.has_color_bitmaps()) {
+ if (auto const* emoji = Emoji::emoji_for_code_point_iterator(it))
+ return font.pixel_size() * emoji->width() / emoji->height();
+ }
return font.glyph_width(*it);
}
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp
index 7b3cb903ee..24463739c5 100644
--- a/Userland/Libraries/LibGfx/Painter.cpp
+++ b/Userland/Libraries/LibGfx/Painter.cpp
@@ -1421,8 +1421,9 @@ void Painter::draw_glyph_or_emoji(FloatPoint point, Utf8CodePointIterator& it, F
++it;
};
+ // NOTE: We don't check for emoji
auto font_contains_glyph = font.contains_glyph(code_point);
- auto check_for_emoji = Unicode::could_be_start_of_emoji_sequence(it, font_contains_glyph ? Unicode::SequenceType::EmojiPresentation : Unicode::SequenceType::Any);
+ auto check_for_emoji = !font.has_color_bitmaps() && Unicode::could_be_start_of_emoji_sequence(it, font_contains_glyph ? Unicode::SequenceType::EmojiPresentation : Unicode::SequenceType::Any);
// If the font contains the glyph, and we know it's not the start of an emoji, draw a text glyph.
if (font_contains_glyph && !check_for_emoji) {