From 4045ac2b6df9f3107bbe020c5edc678f02ec8766 Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Mon, 21 Apr 2025 21:20:38 -0500 Subject: [PATCH] changed scale ChuckBuilds Sign --- ChuckBuilds.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ChuckBuilds.py b/ChuckBuilds.py index 985888d8..25dccc76 100644 --- a/ChuckBuilds.py +++ b/ChuckBuilds.py @@ -45,18 +45,16 @@ def main(): max_font_size = 36 font_size = min_font_size while font_size <= max_font_size: + font = ImageFont.truetype(font_path, font_size) bbox = draw.textbbox((0, 0), text, font=font) text_width = bbox[2] - bbox[0] text_height = bbox[3] - bbox[1] - if text_width > matrix.width or text_height > matrix.height: + if text_width <= matrix.width and text_height <= matrix.height: + font_size += 1 + else: font_size -= 1 font = ImageFont.truetype(font_path, font_size) break - font_size += 1 - else: - # If the loop exits without breaking, use the maximum font size - font_size = max_font_size - font = ImageFont.truetype(font_path, font_size) # Center the text x = (matrix.width - text_width) // 2