fix: use the code provided by @ThiefMaster

https://github.com/lepture/captcha/issues/63
This commit is contained in:
Hsiaoming Yang
2023-07-29 10:29:01 +09:00
parent 100e05a8a3
commit e3710ea00a

View File

@@ -103,7 +103,10 @@ class ImageCaptcha:
draw: ImageDraw,
color: ColorTuple) -> Image:
font = random.choice(self.truefonts)
_, _, w, h = draw.textbbox((1, 1), c, font=font)
left, top, right, bottom = draw.textbbox((0, 0), c, font=font)
w = int((right - left)*1.7) or 1
h = int((bottom - top)*1.7) or 1
dx1 = random.randint(0, 4)
dy1 = random.randint(0, 6)