修复pillow10不支持的textsize (#487)

This commit is contained in:
Cathgao 2024-03-14 12:30:04 +08:00 committed by GitHub
parent a5921148ff
commit d2069ac23f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -217,7 +217,7 @@ class PMImage:
height: Tuple[int, int],
font: ImageFont.ImageFont,
color: Union[str, Tuple[int, int, int, int]] = 'white'):
text_height = self.draw.textsize(text, font=font)[1]
text_height = self.draw.textbbox((0, 0), text = text, font=font)[3] - self.draw.textbbox((0, 0), text = text, font=font)[1]
width_now = width[0]
height_now = height[0]
for c in text: