From 89d5797705de95070adfd9a57f02372002e30df4 Mon Sep 17 00:00:00 2001 From: sin-ack Date: Tue, 27 Jul 2021 21:11:05 +0000 Subject: [PATCH] LibGfx: Remove extra space considered during wrapping This was previously required because the whitespace was consumed and manually added back after the fact, but now that we preserve whitespace, this breaks wrapping of text with whitespace after it. --- Userland/Libraries/LibGfx/TextLayout.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/Userland/Libraries/LibGfx/TextLayout.cpp b/Userland/Libraries/LibGfx/TextLayout.cpp index ea99ca9307..bfe053e57a 100644 --- a/Userland/Libraries/LibGfx/TextLayout.cpp +++ b/Userland/Libraries/LibGfx/TextLayout.cpp @@ -139,24 +139,15 @@ Vector TextLayout::wrap_lines(TextElision elision, TextWrapping wrap case BlockType::Word: { size_t block_width = font().width(block.characters); - if (line_width > 0) { - block_width += font().glyph_width('x'); - - if (wrapping == TextWrapping::Wrap && line_width + block_width > static_cast(m_rect.width())) { - lines.append(builder.to_string()); - builder.clear(); - line_width = 0; - - if (lines.size() == max_lines_that_can_fit && fit_within_rect == FitWithinRect::Yes) { - did_not_finish = true; - goto blocks_processed; - } - } + if (wrapping == TextWrapping::Wrap && line_width + block_width > static_cast(m_rect.width())) { + lines.append(builder.to_string()); + builder.clear(); + line_width = 0; } if (lines.size() == max_lines_that_can_fit && fit_within_rect == FitWithinRect::Yes) { did_not_finish = true; - break; + goto blocks_processed; } builder.append(block.characters.as_string());