From 546f24863d1bad42143ed6feefa5c27c551959a5 Mon Sep 17 00:00:00 2001 From: xsling Date: Sat, 14 Oct 2023 12:43:28 -0700 Subject: [PATCH] Replace deprecated FreeTypeFont.getsize() --- utils/text_to_img.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/text_to_img.py b/utils/text_to_img.py index e76ca38e..b651b2b5 100644 --- a/utils/text_to_img.py +++ b/utils/text_to_img.py @@ -225,8 +225,10 @@ def text_to_image_raw(text, width=config.text_to_image.width, font_name=config.t lines = text.split('\n') line_lengths = [draw.textlength(line, font=font) for line in lines] text_width = max(line_lengths) - text_height = font.getsize(text)[1] - char_width = font.getsize('.')[0] + _, top, _, bottom = font.getbbox(text) + text_height = bottom - top + left, _, right, _ = font.getbbox('.') + char_width = right - left wrapper = TextWrapper(width=int(width / char_width), break_long_words=True) wrapped_text = [wrapper.wrap(i) for i in lines if i != '']