diff --git a/pg.py b/pg.py index 3db3a17..a6e1700 100644 --- a/pg.py +++ b/pg.py @@ -264,10 +264,10 @@ class MultilineText: self.max_chars = max_chars if char_width is None: - char_width = font.render(".", True, white).get_width() # get the width of a character by the font + char_width = font.render(text, True, white).get_width() // len(text) # get the width of a character by the font if max_chars is None and not max_width is None: - self.max_width = max_width // char_width + self.max_width = max_width // char_width - 10 self.surface = self.generate_surface() @@ -282,6 +282,7 @@ class MultilineText: if char == "\n": lines.append(line) length = 1 + line = "" else: line += char @@ -294,6 +295,8 @@ class MultilineText: lines.append(line) length = 1 + line = "" + if not char == "\n": line = char