Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/PIL/ImageFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ def _load_pilfont(self, filename: str) -> None:
def _load_pilfont_data(self, file: IO[bytes], image: Image.Image) -> None:
# check image
if image.mode not in ("1", "L"):
image.close()

msg = "invalid font image mode"
raise TypeError(msg)

# read PILfont header
if file.read(8) != b"PILfont\n":
image.close()

msg = "Not a PILfont file"
raise SyntaxError(msg)
file.readline()
Expand Down
Loading