From 378297571852f2ac6eec2bc18b75246953e8c039 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 5 Dec 2024 17:57:30 +0000 Subject: [PATCH] LibWeb/Layout: Use GlyphRun font to measure trimmed whitespace --- Libraries/LibWeb/Layout/LineBox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibWeb/Layout/LineBox.cpp b/Libraries/LibWeb/Layout/LineBox.cpp index a5bcff175ca..82f743e1468 100644 --- a/Libraries/LibWeb/Layout/LineBox.cpp +++ b/Libraries/LibWeb/Layout/LineBox.cpp @@ -92,8 +92,8 @@ void LineBox::trim_trailing_whitespace() if (!is_ascii_space(last_character)) break; - // FIXME: Use fragment's glyph run to determine the width of the last character. - int last_character_width = last_fragment->layout_node().first_available_font().glyph_width(last_character); + auto const& font = last_fragment->glyph_run() ? last_fragment->glyph_run()->font() : last_fragment->layout_node().first_available_font(); + int last_character_width = font.glyph_width(last_character); last_fragment->m_length -= 1; last_fragment->set_inline_length(last_fragment->inline_length() - last_character_width); m_inline_length -= last_character_width;