From c961fb095fd192e1b4c325912d0fdb5ee9a7fc26 Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Fri, 25 Apr 2025 13:57:04 +0100 Subject: [PATCH] ui(raylib): preserve whitespace in wrapped text (#35067) * ui(raylib): preserve whitespace in wrapped text * lint --- system/ui/text.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system/ui/text.py b/system/ui/text.py index 1337887d9b..53ea2333ce 100755 --- a/system/ui/text.py +++ b/system/ui/text.py @@ -27,8 +27,10 @@ def wrap_text(text, font_size, max_width): continue indent = re.match(r"^\s*", paragraph).group() current_line = indent - for word in paragraph.split(): - test_line = current_line + word + " " + words = re.split(r"(\s+)", paragraph[len(indent):]) + while len(words): + word = words.pop(0) + test_line = current_line + word + (words.pop(0) if words else "") if rl.measure_text_ex(font, test_line, font_size, 0).x <= max_width: current_line = test_line else: