From 16e883a9a36818ab34c9b1ef39c051503501d977 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sat, 19 Apr 2025 23:36:03 +0200 Subject: [PATCH] LibGfx+LibWeb: Don't include start.x in GlyphRun width For some reason we were including x offset of start position into glyph run width. This is not correct and would be revealed by the upcoming changes. --- Libraries/LibGfx/TextLayout.cpp | 2 +- Libraries/LibWeb/Layout/InlineLevelIterator.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibGfx/TextLayout.cpp b/Libraries/LibGfx/TextLayout.cpp index e98c8dbcc96..04ccf4a4f9b 100644 --- a/Libraries/LibGfx/TextLayout.cpp +++ b/Libraries/LibGfx/TextLayout.cpp @@ -59,7 +59,7 @@ RefPtr shape_text(FloatPoint baseline_start, float letter_spacing, Utf point.translate_by(letter_spacing, 0); } - auto run = adopt_ref(*new Gfx::GlyphRun(move(glyph_run), font, text_type, point.x())); + auto run = adopt_ref(*new Gfx::GlyphRun(move(glyph_run), font, text_type, point.x() - baseline_start.x())); hb_buffer_reset(buffer); return run; } diff --git a/Libraries/LibWeb/Layout/InlineLevelIterator.cpp b/Libraries/LibWeb/Layout/InlineLevelIterator.cpp index 4c82fccc067..8d4d52f6b85 100644 --- a/Libraries/LibWeb/Layout/InlineLevelIterator.cpp +++ b/Libraries/LibWeb/Layout/InlineLevelIterator.cpp @@ -554,7 +554,7 @@ Optional InlineLevelIterator::next_without_lookahead( auto shape_features = create_and_merge_font_features(); auto glyph_run = Gfx::shape_text({ x, 0 }, letter_spacing.to_float(), chunk.view, chunk.font, text_type, shape_features); - CSSPixels chunk_width = CSSPixels::nearest_value_for(glyph_run->width()); + CSSPixels chunk_width = CSSPixels::nearest_value_for(glyph_run->width() + x); // NOTE: We never consider `content: ""` to be collapsible whitespace. bool is_generated_empty_string = text_node.is_generated() && chunk.length == 0;