From 9b09ddadd0fdc6269f1b09c123742adaf9fe73a7 Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Tue, 22 Apr 2025 20:30:10 -0500 Subject: [PATCH] fix: properly handle BDF font bitmap data format --- src/font_test_manager.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/font_test_manager.py b/src/font_test_manager.py index 9481b8da..83166bea 100644 --- a/src/font_test_manager.py +++ b/src/font_test_manager.py @@ -67,10 +67,13 @@ class FontTestManager: for i in range(bitmap.rows): for j in range(bitmap.width): try: - # Calculate the correct buffer index based on pitch - index = i * bitmap.pitch + j - if index < len(bitmap.buffer) and bitmap.buffer[index]: - draw.point((x + j, y + i), fill=(255, 255, 255)) + # Get the byte containing the pixel + byte_index = i * bitmap.pitch + (j // 8) + if byte_index < len(bitmap.buffer): + byte = bitmap.buffer[byte_index] + # Check if the specific bit is set + if byte & (1 << (7 - (j % 8))): + draw.point((x + j, y + i), fill=(255, 255, 255)) except IndexError: self.logger.warning(f"Index out of range for char '{char}' at position ({i}, {j})") continue