Files
elripalda--psgfx/tools/embed_assets.py
T
2026-09-30 16:15:24 -07:00

27 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Regenerate src/assets_embed.cpp from assets/ (the UI font and the PSGFX mark).
Run from the repository root: python3 tools/embed_assets.py"""
import os
FILES = [
("sora300", "assets/fonts/sora300.woff2"),
("sora400", "assets/fonts/sora400.woff2"),
("sora600", "assets/fonts/sora600.woff2"),
("sora700", "assets/fonts/sora700.woff2"),
("mark_svg", "assets/mark.svg"),
("wordmark_png", "assets/wordmark-ui.png"),
]
out = ["// Generated by tools/embed_assets.py - do not edit.",
"// Sora font (SIL Open Font License 1.1, see assets/fonts/OFL.txt) the PSGFX mark and wordmark.",
"#include <cstddef>"]
for name, path in FILES:
data = open(path, "rb").read()
out.append(f"extern const unsigned char {name}[] = {{")
for i in range(0, len(data), 24):
out.append(" " + ",".join(str(b) for b in data[i:i + 24]) + ",")
out.append("};")
out.append(f"extern const size_t {name}_len = {len(data)};")
open("src/assets_embed.cpp", "w").write("\n".join(out) + "\n")
print("wrote src/assets_embed.cpp")