Skip to content

Commit b5ead8d

Browse files
committed
font_to_py.py: Better exception text if font size > 65535 bytes.
1 parent 7f7b598 commit b5ead8d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

font_to_py.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,10 @@ def append_data(data, char):
418418
append_data(data, self.charset[0]) # data[0] is the default char
419419
for char in sorted(self.keys()):
420420
sparse += ord(char).to_bytes(2, byteorder='little')
421-
sparse += (len(data)).to_bytes(2, byteorder='little') # Start
421+
try:
422+
sparse += (len(data)).to_bytes(2, byteorder='little') # Start
423+
except OverflowError:
424+
raise ValueError("Total size of font bitmap exceeds 65535 bytes.")
422425
append_data(data, char)
423426
return data, index, sparse
424427

0 commit comments

Comments
 (0)