From a3b97683ae543f6c8021b5883d7129ffec4c0c40 Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Thu, 11 Dec 2025 22:52:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E5=86=85=E5=8F=AF=E7=94=A8=E5=AD=97=E4=BD=93=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 尝试多个字体路径,优先使用Liberation字体 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- app.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index a3d9c29..bdf89fc 100755 --- a/app.py +++ b/app.py @@ -1065,9 +1065,19 @@ def generate_captcha(): draw.point((x, y), fill=(random.randint(0, 200), random.randint(0, 200), random.randint(0, 200))) # 绘制验证码文字 - 增大字体 - try: - font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 42) - except: + font = None + font_paths = [ + "/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf", + "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", + "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf", + ] + for font_path in font_paths: + try: + font = ImageFont.truetype(font_path, 42) + break + except: + continue + if font is None: font = ImageFont.load_default() for i, char in enumerate(code):