summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-07-27 21:11:05 +0000
committerAndreas Kling <kling@serenityos.org>2021-07-27 23:47:00 +0200
commit89d5797705de95070adfd9a57f02372002e30df4 (patch)
treef14c3653160edb5d8c5207fde3cb58d40d497422
parent220dd28b02c45f663a71147c6ac18c91d4b02464 (diff)
downloadserenity-89d5797705de95070adfd9a57f02372002e30df4.zip
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.
-rw-r--r--Userland/Libraries/LibGfx/TextLayout.cpp19
1 files 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<String, 32> 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<unsigned>(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<unsigned>(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());