Merge pull request #6341 from radarhere/imagedraw

Only import ImageFont in ImageDraw when necessary
This commit is contained in:
Hugo van Kemenade 2022-06-05 22:25:10 +03:00 committed by GitHub
commit 418820a1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,7 +33,7 @@
import math import math
import numbers import numbers
from . import Image, ImageColor, ImageFont from . import Image, ImageColor
""" """
A simple 2D drawing interface for PIL images. A simple 2D drawing interface for PIL images.
@ -667,6 +667,8 @@ class ImageDraw:
if font is None: if font is None:
font = self.getfont() font = self.getfont()
from . import ImageFont
if not isinstance(font, ImageFont.FreeTypeFont): if not isinstance(font, ImageFont.FreeTypeFont):
raise ValueError("Only supported for TrueType fonts") raise ValueError("Only supported for TrueType fonts")
mode = "RGBA" if embedded_color else self.fontmode mode = "RGBA" if embedded_color else self.fontmode