From 25909eb47f9a59e34b19cbfbde9b2a5fb91da75f Mon Sep 17 00:00:00 2001 From: Yalong Song <144522198+SolveProb@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:12:58 +0800 Subject: [PATCH] bugfix: Solve the problem of text being cut off at the bottom If the maximum value of all character heights is used as the text height, the text will be truncated in the final generated image. Here, 2 times the text height is used as the pre-generated image height to prevent the text area from being truncated. --- trdg/computer_text_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trdg/computer_text_generator.py b/trdg/computer_text_generator.py index eb016e2ef..e9d0033d8 100644 --- a/trdg/computer_text_generator.py +++ b/trdg/computer_text_generator.py @@ -104,7 +104,7 @@ def _generate_horizontal_text( if not word_split: text_width += character_spacing * (len(text) - 1) - text_height = max([get_text_height(image_font, p) for p in splitted_text]) + text_height = max([get_text_height(image_font, p) for p in splitted_text]) * 2 txt_img = Image.new("RGBA", (text_width, text_height), (0, 0, 0, 0)) txt_mask = Image.new("RGB", (text_width, text_height), (0, 0, 0))