This commit is contained in:
2024-05-24 10:09:50 +02:00
parent cfe3d3f329
commit c390a3eb9a
8 changed files with 68 additions and 23 deletions

View File

@ -57,7 +57,7 @@ def make_test_pages(fonts: dict[str, ImageFont.FreeTypeFont]):
final_text = []
current_text = ""
for char in TEST_TEXT:
if font.getsize(current_text + char)[0] > (writable_area):
if font.getbbox(current_text + char)[2] > (writable_area):
final_text.append(current_text)
current_text = char
else:
@ -94,7 +94,7 @@ def make_fonts():
font_path = f"./fonts/{font_name}.{file_type}"
tmp_font = ImageFont.truetype(font_path, FONT_SIZE)
letter_height = int(average([
tmp_font.getsize(i)[1] for i in TEST_TEXT
tmp_font.getbbox(i)[3] for i in TEST_TEXT
]))
new_size = (FONT_SIZE**2)//letter_height
new_font = ImageFont.truetype(font_path, new_size)