From 9bf9b3a910565c0bd7bfca3cc3f417a2358aa6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 19 Aug 2021 22:30:51 +0200 Subject: [PATCH] Do not build avatar if Pillow has not truetype support issue10654 review365761002 --- trytond/ir/avatar.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trytond/ir/avatar.py b/trytond/ir/avatar.py index ab6d638b8d..350a887792 100644 --- a/trytond/ir/avatar.py +++ b/trytond/ir/avatar.py @@ -185,10 +185,13 @@ def generate(size, string): b = random.randint(0, 255) return r, v, b + try: + font = ImageFont.truetype(FONT, size=int(0.65 * size)) + except ImportError: + return white = (255, 255, 255) image = Image.new('RGB', (size, size), background_color(string)) draw = ImageDraw.Draw(image) - font = ImageFont.truetype(FONT, size=int(0.65 * size)) letter = string[0].upper() if string else '' draw.text( (size / 2, size / 2), letter, fill=white, font=font, anchor='mm')