From 3afcbb759c76c7007963222aa68bc006dafba8a8 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:22:54 -0400 Subject: [PATCH] add freetype error handling --- src/of_the_day_manager.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/of_the_day_manager.py b/src/of_the_day_manager.py index 8f304a02..9c506f47 100644 --- a/src/of_the_day_manager.py +++ b/src/of_the_day_manager.py @@ -8,7 +8,10 @@ from rgbmatrix import graphics import pytz from src.config_manager import ConfigManager import time -import freetype +try: + import freetype +except ImportError: + freetype = None # Configure logger for this module logger = logging.getLogger(__name__) @@ -73,7 +76,11 @@ class OfTheDayManager: abs_font_path = os.path.abspath(font_path) if os.path.exists(abs_font_path): logger.debug(f"Loading BDF font: {abs_font_path}") - return freetype.Face(abs_font_path) + if freetype is not None: + return freetype.Face(abs_font_path) + else: + logger.warning("freetype module not available, cannot load BDF fonts") + return None logger.debug(f"Font file not found: {filename}") # List available fonts for debugging @@ -377,7 +384,7 @@ class OfTheDayManager: """Draw text for both BDF (FreeType Face) and PIL TTF fonts.""" try: # If we have a PIL font, use native text rendering - if not isinstance(face, freetype.Face): + if freetype is None or not isinstance(face, freetype.Face): draw.text((x, y), text, fill=color, font=face) return