ui(raylib): preserve whitespace in wrapped text (#35067)

* ui(raylib): preserve whitespace in wrapped text

* lint
pull/35068/head
Cameron Clough 18 hours ago committed by GitHub
parent 37e86df41e
commit c961fb095f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      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:

Loading…
Cancel
Save