1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 10:17:35 +00:00

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.
This commit is contained in:
sin-ack 2021-07-27 21:11:05 +00:00 committed by Andreas Kling
parent 220dd28b02
commit 89d5797705

View file

@ -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());