Improved MultilineText.
This commit is contained in:
parent
3aa6cd9904
commit
727c7bfd5c
1 changed files with 5 additions and 2 deletions
7
pg.py
7
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue