mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +00:00
LibGfx: Consider multi-code point glyphs when computing text width
Currently, we compute the width of text one code point at a time. This ignores grapheme clusters (emoji in particular). One effect of this is when highlighting a multi-code point emoji. We will errantly increase the highlight rect to the sum of all code point widths, rather than just the width of the resolved emoji bitmap.
This commit is contained in:
committed by
Andreas Kling
parent
a391ea3da3
commit
b823f3d29f
@@ -171,8 +171,7 @@ DeprecatedString TextLayout::elide_text_from_right(Utf8View text) const
|
||||
if (ellipsis_width < text_width) {
|
||||
size_t offset = 0;
|
||||
for (auto it = text.begin(); !it.done(); ++it) {
|
||||
auto code_point = *it;
|
||||
auto glyph_width = m_font.glyph_or_emoji_width(code_point);
|
||||
auto glyph_width = m_font.glyph_or_emoji_width(it);
|
||||
// NOTE: Glyph spacing should not be added after the last glyph on the line,
|
||||
// but since we are here because the last glyph does not actually fit on the line,
|
||||
// we don't have to worry about spacing.
|
||||
|
||||
Reference in New Issue
Block a user