From 2b03334fff8d53fc4b89016a0911db82919eceab 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 (grafted from 9ce043f3044b39888e157bdd10d3211275f83c33) --HG-- branch : 6.0 --- 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 1c0d06a75d..9b3a3fbed4 100644 --- a/trytond/ir/avatar.py +++ b/trytond/ir/avatar.py @@ -183,10 +183,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')