changeset 9ce043f3044b in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=9ce043f3044b
description:
        Do not build avatar if Pillow has not truetype support

        issue10654
        review365761002
diffstat:

 trytond/ir/avatar.py |  5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diffs (18 lines):

diff -r 706d02b3cc23 -r 9ce043f3044b trytond/ir/avatar.py
--- a/trytond/ir/avatar.py      Thu Aug 19 22:29:09 2021 +0200
+++ b/trytond/ir/avatar.py      Thu Aug 19 22:30:51 2021 +0200
@@ -185,10 +185,13 @@
             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')

Reply via email to