From 5654345b2ab141bc4f8b59ceed55d488ac7062a2 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Wed, 23 Jul 2025 11:04:49 -0500 Subject: [PATCH] fix bdf text wrapping --- src/of_the_day_manager.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/of_the_day_manager.py b/src/of_the_day_manager.py index 8a7d7352..f3b3d10e 100644 --- a/src/of_the_day_manager.py +++ b/src/of_the_day_manager.py @@ -234,7 +234,11 @@ class OfTheDayManager: words = text.split() for word in words: test_line = ' '.join(current_line + [word]) if current_line else word - text_width = sum([face.get_advance_width(ord(c)) for c in test_line]) // 64 + text_width = 0 + for c in test_line: + face.load_char(c) + text_width += face.glyph.advance.x + text_width = text_width // 64 if text_width <= max_width: current_line.append(word) else: @@ -244,7 +248,11 @@ class OfTheDayManager: else: truncated = word while len(truncated) > 0: - test_width = sum([face.get_advance_width(ord(c)) for c in (truncated + "...")]) // 64 + test_width = 0 + for c in (truncated + "..."): + face.load_char(c) + test_width += face.glyph.advance.x + test_width = test_width // 64 if test_width <= max_width: lines.append(truncated + "...") break