LibHTML: Forgot to account for -1 glyph spacing in text layout

Font::width(string) will subtract one Font::glyph_spacing() from the
result, since we don't put any spacing after the last glyph.

This was messing up text layout here, since we assumed each glyph
width also included the glyph spacing.
This commit is contained in:
Andreas Kling 2019-10-03 16:05:32 +02:00
commit 84ec286060
Notes: sideshowbarker 2024-07-19 11:49:56 +09:00

View file

@ -198,7 +198,6 @@ void LayoutText::split_into_lines(LayoutBlock& container)
for_each_word([&](const Utf8View& view, int start, int length) { for_each_word([&](const Utf8View& view, int start, int length) {
words.append({ Utf8View(view), start, length }); words.append({ Utf8View(view), start, length });
}); });
for (int i = 0; i < words.size(); ++i) { for (int i = 0; i < words.size(); ++i) {
@ -210,7 +209,7 @@ void LayoutText::split_into_lines(LayoutBlock& container)
if (is_whitespace) if (is_whitespace)
word_width = space_width; word_width = space_width;
else else
word_width = m_font->width(word.view); word_width = m_font->width(word.view) + m_font->glyph_spacing();
if (word_width > available_width) { if (word_width > available_width) {
line_boxes.append(LineBox()); line_boxes.append(LineBox());