Skip to content
Snippets Groups Projects
Verified Commit 1a001de2 authored by TheJoeCoder's avatar TheJoeCoder
Browse files

Add fonts

parent b6049e37
No related branches found
No related tags found
No related merge requests found
Showing
with 25 additions and 0 deletions
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
......@@ -40,6 +40,15 @@ mainthread_queue = queue.Queue()
api_queue = queue.Queue()
led_queue = queue.Queue()
@app.route("/")
def wr_index():
return f"""
<h1>LED Clock</h1>
Available widgets: {PROP_AVAILABLE_WIDGETS}<br>
Available patterns: {PROP_AVAILABLE_PATTERNS}<br>
<a href="/api/get_config">Config</a>
"""
@app.route("/api/available_fonts")
def wr_available_fonts():
return Response(json.dumps(pygame.font.get_fonts()), mimetype="application/json")
......
import os
import re
from config import *
import socket
......@@ -29,3 +32,16 @@ def get_ip():
finally:
s.close()
return ip_addr
def get_font_path_or_default(pygame, font_name: str|None, bold=False, italic=False) -> str:
if font_name is not None:
if re.match(r".+\.ttf", font_name):
if os.path.exists(font_name):
font_path = font_name
else:
font_path = pygame.font.get_default_font()
else:
font_path = pygame.font.match_font(font_name, bold, italic)
else:
font_path = pygame.font.get_default_font()
return font_path
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment