1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:47:45 +00:00

LibGfx: Always scale emojis to fit font height

This commit is contained in:
Maciej 2022-01-21 18:48:47 +01:00 committed by Linus Groh
parent 7a92842017
commit 8542d1da5a
2 changed files with 8 additions and 12 deletions

View file

@ -314,7 +314,7 @@ int BitmapFont::glyph_or_emoji_width_for_variable_width_font(u32 code_point) con
auto* emoji = Emoji::emoji_for_code_point(code_point);
if (emoji == nullptr)
return glyph_width(0xFFFD);
return emoji->size().width();
return glyph_height() * emoji->width() / emoji->height();
}
int BitmapFont::width(StringView view) const { return unicode_view_width(Utf8View(view)); }

View file

@ -1226,17 +1226,13 @@ FLATTEN void Painter::draw_glyph(IntPoint const& point, u32 code_point, Font con
void Painter::draw_emoji(IntPoint const& point, Gfx::Bitmap const& emoji, Font const& font)
{
if (!font.is_fixed_width())
blit(point, emoji, emoji.rect());
else {
IntRect dst_rect {
point.x(),
point.y(),
font.glyph_width('x'),
font.glyph_height()
};
draw_scaled_bitmap(dst_rect, emoji, emoji.rect());
}
IntRect dst_rect {
point.x(),
point.y(),
font.glyph_height() * emoji.width() / emoji.height(),
font.glyph_height()
};
draw_scaled_bitmap(dst_rect, emoji, emoji.rect());
}
void Painter::draw_glyph_or_emoji(IntPoint const& point, u32 code_point, Font const& font, Color color)