Skip to content

Commit

Permalink
Improve error message when creating TrueType fonts of negative size
Browse files Browse the repository at this point in the history
Fixes #7583
  • Loading branch information
akx committed Nov 28, 2023
1 parent a1d2297 commit 0f788b3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/PIL/ImageFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,10 @@ def truetype(font=None, size=10, index=0, encoding="", layout_engine=None):
:exception OSError: If the file could not be read.
"""

if size <= 0:
msg = "font size must be positive"
raise ValueError(msg)

def freetype(font):
return FreeTypeFont(font, size, index, encoding, layout_engine)

Expand Down

0 comments on commit 0f788b3

Please sign in to comment.