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

        issue10654
        review365761002
        (grafted from 9ce043f3044b39888e157bdd10d3211275f83c33)
diffstat:

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

diffs (18 lines):

diff -r cd359f6895b2 -r 2c2b1e06d3f7 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
@@ -183,10 +183,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