mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-13 05:53:00 +00:00
fix bdf font positioning for displays negatively impacted by previous change
This commit is contained in:
@@ -279,10 +279,14 @@ class DisplayManager:
|
|||||||
|
|
||||||
# Draw the text
|
# Draw the text
|
||||||
if isinstance(current_font, freetype.Face):
|
if isinstance(current_font, freetype.Face):
|
||||||
# For BDF fonts, use _draw_bdf_text
|
# For BDF fonts, we need to adjust the y-coordinate.
|
||||||
self._draw_bdf_text(text, x, y, color, current_font)
|
# The passed 'y' is the top of the text, but our drawing function
|
||||||
|
# expects the baseline. The 'ascender' is the distance from the
|
||||||
|
# baseline to the top of the glyphs.
|
||||||
|
baseline_y = y + (current_font.size.ascender >> 6)
|
||||||
|
self._draw_bdf_text(text, x, baseline_y, color, current_font)
|
||||||
else:
|
else:
|
||||||
# For TTF fonts, use PIL's text drawing
|
# For TTF fonts, use PIL's text drawing which expects top-left.
|
||||||
self.draw.text((x, y), text, font=current_font, fill=color)
|
self.draw.text((x, y), text, font=current_font, fill=color)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user