1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

LibGUI: Use Font::glyph_or_emoji_width() in TextEditor

This fixes selection of text containing emoji when variable-width font
is set.
This commit is contained in:
Maciej 2022-01-21 18:48:10 +01:00 committed by Linus Groh
parent 8542d1da5a
commit b6d6cc5de4

View file

@ -170,7 +170,7 @@ TextPosition TextEditor::text_position_at_content_position(Gfx::IntPoint const&
int glyph_x = 0;
size_t i = 0;
for (; i < view.length(); ++i) {
int advance = font().glyph_width(view.code_points()[i]) + font().glyph_spacing();
int advance = font().glyph_or_emoji_width(view.code_points()[i]) + font().glyph_spacing();
if ((glyph_x + (advance / 2)) >= position.x())
break;
glyph_x += advance;