mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
changed scale ChuckBuilds Sign
This commit is contained in:
@@ -45,18 +45,16 @@ def main():
|
|||||||
max_font_size = 36
|
max_font_size = 36
|
||||||
font_size = min_font_size
|
font_size = min_font_size
|
||||||
while font_size <= max_font_size:
|
while font_size <= max_font_size:
|
||||||
|
font = ImageFont.truetype(font_path, font_size)
|
||||||
bbox = draw.textbbox((0, 0), text, font=font)
|
bbox = draw.textbbox((0, 0), text, font=font)
|
||||||
text_width = bbox[2] - bbox[0]
|
text_width = bbox[2] - bbox[0]
|
||||||
text_height = bbox[3] - bbox[1]
|
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_size -= 1
|
||||||
font = ImageFont.truetype(font_path, font_size)
|
font = ImageFont.truetype(font_path, font_size)
|
||||||
break
|
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
|
# Center the text
|
||||||
x = (matrix.width - text_width) // 2
|
x = (matrix.width - text_width) // 2
|
||||||
|
|||||||
Reference in New Issue
Block a user