@@ -631,7 +631,7 @@ def _get_wrapped_text(self):
631631
632632 # Build the line incrementally, for a more accurate measure of length
633633 line_width = self ._get_wrap_line_width ()
634- wrapped_str = ""
634+ wrapped_lines = []
635635
636636 # New lines in the user's text force a split
637637 unwrapped_lines = self .get_text ().split ('\n ' )
@@ -644,7 +644,7 @@ def _get_wrapped_text(self):
644644 while len (sub_words ) > 0 :
645645 if len (sub_words ) == 1 :
646646 # 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 ) )
648648 continue
649649
650650 for i in range (2 , len (sub_words ) + 1 ):
@@ -655,17 +655,17 @@ def _get_wrapped_text(self):
655655 # If all these words are too wide, append all not including
656656 # last word
657657 if current_width > line_width :
658- wrapped_str += ' ' .join (sub_words [:i - 1 ]) + ' \n '
658+ wrapped_lines . append ( ' ' .join (sub_words [:i - 1 ]))
659659 sub_words = sub_words [i - 1 :]
660660 break
661661
662662 # Otherwise if all words fit in the width, append them all
663663 elif i == len (sub_words ):
664- wrapped_str += ' ' .join (sub_words [:i ])
664+ wrapped_lines . append ( ' ' .join (sub_words [:i ]) )
665665 sub_words = []
666666 break
667667
668- return wrapped_str
668+ return ' \n ' . join ( wrapped_lines )
669669
670670 @artist .allow_rasterization
671671 def draw (self , renderer ):
0 commit comments