fix(display): Use normalized absolute path for 4x6 font

Calculate path relative to script, then normalize to absolute path before loading.
This commit is contained in:
ChuckBuilds
2025-04-15 15:11:38 -05:00
parent 57e5d801c7
commit 7efaa2e3b9

View File

@@ -130,11 +130,15 @@ class DisplayManager:
self.small_font = ImageFont.truetype("assets/fonts/PressStart2P-Regular.ttf", 8)
logger.info("Press Start 2P small font loaded successfully")
# Add an even smaller font using 4x6.bdf assuming script runs from project root
# Add an even smaller font using 4x6.bdf
try:
# Hardcoded relative path from project root
font_path = "assets/fonts/4x6.bdf"
print(f"Attempting to load font from (hardcoded relative): {font_path}") # DEBUG PRINT
# Get directory containing this script
script_dir = os.path.dirname(os.path.abspath(__file__))
# Construct path relative to this script
relative_font_path = os.path.join(script_dir, "../assets/fonts/4x6.bdf")
# Normalize to absolute path
font_path = os.path.abspath(relative_font_path)
print(f"Attempting to load font from (normalized absolute): {font_path}") # DEBUG PRINT
self.extra_small_font = ImageFont.load(font_path)
logger.info(f"4x6.bdf extra small font loaded successfully from {font_path}")
except Exception as font_err: