@@ -631,7 +631,7 @@ def _get_wrapped_text(self):
631
631
632
632
# Build the line incrementally, for a more accurate measure of length
633
633
line_width = self ._get_wrap_line_width ()
634
- wrapped_str = ""
634
+ wrapped_lines = []
635
635
636
636
# New lines in the user's text force a split
637
637
unwrapped_lines = self .get_text ().split ('\n ' )
@@ -644,7 +644,7 @@ def _get_wrapped_text(self):
644
644
while len (sub_words ) > 0 :
645
645
if len (sub_words ) == 1 :
646
646
# Only one word, so just add it to the end
647
- wrapped_str += sub_words .pop (0 )
647
+ wrapped_lines . append ( sub_words .pop (0 ) )
648
648
continue
649
649
650
650
for i in range (2 , len (sub_words ) + 1 ):
@@ -655,17 +655,17 @@ def _get_wrapped_text(self):
655
655
# If all these words are too wide, append all not including
656
656
# last word
657
657
if current_width > line_width :
658
- wrapped_str += ' ' .join (sub_words [:i - 1 ]) + ' \n '
658
+ wrapped_lines . append ( ' ' .join (sub_words [:i - 1 ]))
659
659
sub_words = sub_words [i - 1 :]
660
660
break
661
661
662
662
# Otherwise if all words fit in the width, append them all
663
663
elif i == len (sub_words ):
664
- wrapped_str += ' ' .join (sub_words [:i ])
664
+ wrapped_lines . append ( ' ' .join (sub_words [:i ]) )
665
665
sub_words = []
666
666
break
667
667
668
- return wrapped_str
668
+ return ' \n ' . join ( wrapped_lines )
669
669
670
670
@artist .allow_rasterization
671
671
def draw (self , renderer ):
0 commit comments