Moved error from truetype() to FreeTypeFont

This commit is contained in:
Andrew Murray 2023-11-30 07:41:02 +11:00
parent e1291b880d
commit f23d029d5f

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)