From d9349f1510201dba77061de03a5c3147c58e9e4b Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 8 Mar 2024 09:33:06 -0500 Subject: [PATCH] LibGfx: Treat "\r\n" as a single line break during text layout We currently insert two line breaks for this sequence. This Windows- style of line breaking can be seen in documents on the web. --- Userland/Libraries/LibGfx/TextLayout.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/TextLayout.cpp b/Userland/Libraries/LibGfx/TextLayout.cpp index 7941b29f81..54a6b6f15b 100644 --- a/Userland/Libraries/LibGfx/TextLayout.cpp +++ b/Userland/Libraries/LibGfx/TextLayout.cpp @@ -73,8 +73,11 @@ Vector TextLayout::wrap_lines(TextElision elision, TextWrapping continue; } - case '\n': - case '\r': { + case '\r': + if (it.peek(1) == static_cast('\n')) + ++it; + [[fallthrough]]; + case '\n': { if (current_block_type.has_value()) { blocks.append({ current_block_type.value(),