Update display_manager.py

font changes to dejavu thinnest
This commit is contained in:
Chuck
2025-04-08 18:59:15 -05:00
parent 1678c6fdba
commit d9a9ca3e17

View File

@@ -124,18 +124,19 @@ class DisplayManager:
def _load_fonts(self): def _load_fonts(self):
"""Load fonts optimized for LED matrix display.""" """Load fonts optimized for LED matrix display."""
try: try:
# Use DejaVu Sans with optimized sizes # Use DejaVu Sans ExtraLight for thinnest possible characters
matrix_height = self.matrix.height font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-ExtraLight.ttf"
# For 32px height matrix, use 16px for large text and 8px for small
large_size = 16 # Fixed size instead of percentage # For 32px height matrix, optimized sizes for ExtraLight
small_size = 8 # Fixed size for better clarity large_size = 20 # Slightly larger since ExtraLight is very thin
small_size = 10 # Slightly larger for better visibility
try: try:
self.font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", large_size) self.font = ImageFont.truetype(font_path, large_size)
self.small_font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", small_size) self.small_font = ImageFont.truetype(font_path, small_size)
logger.info(f"Using DejaVu Sans with sizes {large_size}px and {small_size}px") logger.info(f"Loaded ExtraLight font: {font_path} (large: {large_size}px, small: {small_size}px)")
except Exception as e: except Exception as e:
logger.error(f"Failed to load DejaVu Sans: {e}") logger.warning(f"Failed to load ExtraLight font, falling back to default: {e}")
self.font = ImageFont.load_default() self.font = ImageFont.load_default()
self.small_font = ImageFont.load_default() self.small_font = ImageFont.load_default()
@@ -169,7 +170,7 @@ class DisplayManager:
y = min(y, max_y) y = min(y, max_y)
y = max(y, padding) # Ensure text doesn't get cut off at top y = max(y, padding) # Ensure text doesn't get cut off at top
# Draw text # For Light font, we can use full brightness since the characters are thinner
self.draw.text((x, y), text, font=font, fill=color) self.draw.text((x, y), text, font=font, fill=color)
def draw_sun(self, x: int, y: int, size: int = 16): def draw_sun(self, x: int, y: int, size: int = 16):