Add bundled bus fonts and shared font favorites

This commit is contained in:
2026-10-12 15:00:40 +08:00
parent c9dd03c23b
commit 4be74a34f9
181 changed files with 2078575 additions and 76 deletions
+15
View File
@@ -134,6 +134,12 @@ def normalize_if_match(value: str | None) -> str:
return candidate
class FontFavoriteRequest(BaseModel):
model_config = ConfigDict(extra="forbid")
id: StrictStr = Field(min_length=1, max_length=512)
favorite: StrictBool
class ConfigUpdate(BaseModel):
orientation: int | None = None
brightness: int | None = None
@@ -991,6 +997,15 @@ def create_app(
def get_fonts() -> dict:
return fonts.document()
@app.put("/api/fonts/favorite")
def update_font_favorite(payload: FontFavoriteRequest) -> dict:
try:
return {"favorite_ids": fonts.set_favorite(payload.id, payload.favorite)}
except KeyError:
raise HTTPException(status_code=404, detail="font is not available")
except OSError:
raise HTTPException(status_code=500, detail="font favorite could not be saved")
@app.post("/api/fonts/import")
async def import_font(request: Request, response: Response, filename: str = "") -> dict:
content_type = request.headers.get("content-type", "").split(";", 1)[0].strip().casefold()