Fix kneeboard notes bug

This commit is contained in:
Raffson 2023-10-14 15:17:52 +02:00
parent b2c38f454f
commit 06f51573e1
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99

View File

@ -171,14 +171,14 @@ class KneeboardPageWriter:
def wrap_line_with_font(
inputstr: str, max_width: int, font: ImageFont.FreeTypeFont
) -> str:
if font.getsize(inputstr)[0] <= max_width: # type:ignore[attr-defined]
if font.getlength(inputstr) <= max_width:
return inputstr
tokens = inputstr.split(" ")
output = ""
segments = []
for token in tokens:
combo = output + " " + token
if font.getsize(combo)[0] > max_width: # type:ignore[attr-defined]
if font.getlength(combo) > max_width:
segments.append(output + "\n")
output = token
else: