From e96177451e2c0e408d7e7f1c3531f0c998dcf17c Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 30 May 2022 19:36:36 +1000 Subject: [PATCH] Only import ImageFont when necessary --- src/PIL/ImageDraw.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index f9782bc501a..3824626bd6a 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -33,7 +33,7 @@ import math import numbers -from . import Image, ImageColor, ImageFont +from . import Image, ImageColor """ A simple 2D drawing interface for PIL images. @@ -667,6 +667,8 @@ def textbbox( if font is None: font = self.getfont() + from . import ImageFont + if not isinstance(font, ImageFont.FreeTypeFont): raise ValueError("Only supported for TrueType fonts") mode = "RGBA" if embedded_color else self.fontmode