Do not build avatar if Pillow has not truetype support

issue10654
review365761002
This commit is contained in:
Cédric Krier committed 2021-08-19 22:30:51 +02:00
1 parent d9d36d476a
commit 9bf9b3a910
1 file changed
+4 -1
+4 -1
View File
@@ -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')