|
|
@ -27,8 +27,10 @@ def wrap_text(text, font_size, max_width): |
|
|
|
continue |
|
|
|
continue |
|
|
|
indent = re.match(r"^\s*", paragraph).group() |
|
|
|
indent = re.match(r"^\s*", paragraph).group() |
|
|
|
current_line = indent |
|
|
|
current_line = indent |
|
|
|
for word in paragraph.split(): |
|
|
|
words = re.split("(\s+)", paragraph[len(indent):]) |
|
|
|
test_line = current_line + word + " " |
|
|
|
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: |
|
|
|
if rl.measure_text_ex(font, test_line, font_size, 0).x <= max_width: |
|
|
|
current_line = test_line |
|
|
|
current_line = test_line |
|
|
|
else: |
|
|
|
else: |
|
|
|