mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 21:03:01 +00:00
loading fonts va absolute paths
This commit is contained in:
@@ -428,14 +428,11 @@ class StockManager:
|
||||
fallback = Image.new('RGBA', (32, 32), (0, 0, 0, 0))
|
||||
draw = ImageDraw.Draw(fallback)
|
||||
try:
|
||||
# Resolve font path absolutely to avoid fallback under systemd; fall back to PS2P if missing
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
font_path = os.path.abspath(os.path.join(script_dir, "../assets/fonts/OpenSans-Regular.ttf"))
|
||||
# Try to load OpenSans font first, fall back to PS2P if missing
|
||||
try:
|
||||
font = ImageFont.truetype(font_path, 16)
|
||||
font = ImageFont.truetype("assets/fonts/OpenSans-Regular.ttf", 16)
|
||||
except Exception:
|
||||
ps2p = os.path.abspath(os.path.join(script_dir, "../assets/fonts/PressStart2P-Regular.ttf"))
|
||||
font = ImageFont.truetype(ps2p, 8)
|
||||
font = ImageFont.truetype("assets/fonts/PressStart2P-Regular.ttf", 8)
|
||||
except:
|
||||
font = ImageFont.load_default()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user