diff --git a/Tests/LibWeb/Layout/expected/textnode-width-bitmap-font.txt b/Tests/LibWeb/Layout/expected/textnode-width-bitmap-font.txt new file mode 100644 index 0000000000..26596af345 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/textnode-width-bitmap-font.txt @@ -0,0 +1,17 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x38 [BFC] children: not-inline + BlockContainer at (8,13) content-size 784x17 children: not-inline + BlockContainer

at (8,13) content-size 784x17 children: inline + line 0 width: 102, height: 17, bottom: 17, baseline: 11 + frag 0 from TextNode start: 0, length: 18, rect: [8,13 102x17] + "This is some text." + TextNode <#text> + BlockContainer <(anonymous)> at (8,43) content-size 784x0 children: inline + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x38] overflow: [0,0 800x43] + PaintableWithLines (BlockContainer) [8,13 784x17] overflow: [8,13 784x30] + PaintableWithLines (BlockContainer

) [8,13 784x17] + TextPaintable (TextNode<#text>) + PaintableWithLines (BlockContainer(anonymous)) [8,43 784x0] diff --git a/Tests/LibWeb/Layout/input/textnode-width-bitmap-font.html b/Tests/LibWeb/Layout/input/textnode-width-bitmap-font.html new file mode 100644 index 0000000000..764edb496b --- /dev/null +++ b/Tests/LibWeb/Layout/input/textnode-width-bitmap-font.html @@ -0,0 +1 @@ +

This is some text.

diff --git a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp index bb9353d59c..be7f5a5e68 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp @@ -180,7 +180,6 @@ Optional InlineLevelIterator::next_without_lookahead( m_text_node_context->is_last_chunk = true; auto& chunk = chunk_opt.value(); - CSSPixels chunk_width = CSSPixels::nearest_value_for(text_node.font().width(chunk.view) + text_node.font().glyph_spacing()); if (m_text_node_context->do_respect_linebreaks && chunk.has_breaking_newline) { return Item { @@ -188,6 +187,13 @@ Optional InlineLevelIterator::next_without_lookahead( }; } + CSSPixels chunk_width; + + if (m_text_node_context->is_last_chunk) + chunk_width = CSSPixels::nearest_value_for(text_node.font().width(chunk.view)); + else + chunk_width = CSSPixels::nearest_value_for(text_node.font().width(chunk.view) + text_node.font().glyph_spacing()); + // NOTE: We never consider `content: ""` to be collapsible whitespace. bool is_generated_empty_string = text_node.is_generated() && chunk.length == 0;