Merge pull request #7587 from radarhere/freetypefont

Moved error from truetype() to FreeTypeFont
This commit is contained in:
Andrew Murray 2023-12-04 22:05:38 +11:00 committed by GitHub
commit b51dcc070b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,6 +188,10 @@ class FreeTypeFont:
def __init__(self, font=None, size=10, index=0, encoding="", layout_engine=None):
# FIXME: use service provider instead
if size <= 0:
msg = "font size must be greater than 0"
raise ValueError(msg)
self.path = font
self.size = size
self.index = index
@ -791,10 +795,6 @@ def truetype(font=None, size=10, index=0, encoding="", layout_engine=None):
:exception ValueError: If the font size is not greater than zero.
"""
if size <= 0:
msg = "font size must be greater than 0"
raise ValueError(msg)
def freetype(font):
return FreeTypeFont(font, size, index, encoding, layout_engine)