✨
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user