This commit is contained in:
NikolajDanger
2022-06-02 16:41:35 +02:00
parent 41b5adf9f5
commit 95e70c76a4
39 changed files with 14 additions and 12 deletions

View File

@ -2,6 +2,7 @@ import string
import pathlib
import time
from PIL import ImageFont, Image, ImageDraw
from numpy import average
BASE64_DIGITS = string.digits + string.ascii_letters + "+_"
@ -92,7 +93,9 @@ def make_fonts():
font_path = f"./fonts/{font_name}.{file_type}"
tmp_font = ImageFont.truetype(font_path, FONT_SIZE)
letter_height = tmp_font.getsize("A")[1]
letter_height = int(average([
tmp_font.getsize(i)[1] for i in TEST_TEXT
]))
new_size = (FONT_SIZE**2)//letter_height
new_font = ImageFont.truetype(font_path, new_size)
image_fonts[font_name] = new_font