a
This commit is contained in:
parent
9811a0d0ad
commit
54277a7208
|
@ -13,7 +13,9 @@ class FontManager:
|
|||
line = ""
|
||||
for word in words:
|
||||
test = f"{line} {word}".strip()
|
||||
if draw.textlength(test, font=self.font) <= width:
|
||||
bbox = self.font.getbbox(test)
|
||||
test_width = bbox[2] - bbox[0]
|
||||
if test_width <= width:
|
||||
line = test
|
||||
else:
|
||||
lines.append(line)
|
||||
|
@ -23,3 +25,8 @@ class FontManager:
|
|||
draw.rectangle((0, 0, width, height), outline=0, fill=0)
|
||||
for idx, line in enumerate(lines):
|
||||
draw.text((x, y + idx * self.font.size), line, font=self.font, fill=255)
|
||||
|
||||
|
||||
draw.rectangle((0, 0, width, height), outline=0, fill=0)
|
||||
for idx, line in enumerate(lines):
|
||||
draw.text((x, y + idx * self.font.size), line, font=self.font, fill=255)
|
||||
|
|
Loading…
Reference in a new issue