mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +00:00
LibWeb: Don't add an extra glyph spacing to width of TextNode
When calculating the width of text using a bitmap font, a glyph spacing is added at the end of each fragment, including the last one. This meant that everything was 1 pixel too long. This bug did not affect vector fonts.
This commit is contained in:
@@ -180,7 +180,6 @@ Optional<InlineLevelIterator::Item> 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::Item> 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user