mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-11 21:33:00 +00:00
fix: properly handle BDF font bitmap data format
This commit is contained in:
@@ -67,10 +67,13 @@ class FontTestManager:
|
|||||||
for i in range(bitmap.rows):
|
for i in range(bitmap.rows):
|
||||||
for j in range(bitmap.width):
|
for j in range(bitmap.width):
|
||||||
try:
|
try:
|
||||||
# Calculate the correct buffer index based on pitch
|
# Get the byte containing the pixel
|
||||||
index = i * bitmap.pitch + j
|
byte_index = i * bitmap.pitch + (j // 8)
|
||||||
if index < len(bitmap.buffer) and bitmap.buffer[index]:
|
if byte_index < len(bitmap.buffer):
|
||||||
draw.point((x + j, y + i), fill=(255, 255, 255))
|
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:
|
except IndexError:
|
||||||
self.logger.warning(f"Index out of range for char '{char}' at position ({i}, {j})")
|
self.logger.warning(f"Index out of range for char '{char}' at position ({i}, {j})")
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user