GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — SampleBoot/tools/build_editor.py at main · pxcm/SampleBoot

Expand file tree

/

build_editor.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
34 lines (33 loc) · 2.1 KB
/

build_editor.py

Copy path

File metadata and controls

34 lines (33 loc) · 2.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
"""Assembles tools/theme-editor.html from tools/editor/editor.html: puts in the
same glyphs sampleboot-ui draws with (src/font_data.h), the test images
(tools/editor/images.json) and the original settings (card/sampleboot.conf), so
the page is a single self-contained file. Standard library only."""
import base64, json, re
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
header = (ROOT / "src" / "font_data.h").read_text()
fonts = {}
for short, name in (("small", "font_small"), ("label", "font_label"), ("name", "font_name"), ("big", "font_big")):
px = bytes(int(x) for x in re.search(r"static const uint8_t %s_px\[\] = \{([^}]*)\}" % name, header).group(1).split(","))
g = [[int(v) for v in t.split(",")] for t in
re.findall(r"\{(-?\d+,-?\d+,-?\d+,-?\d+,-?\d+,-?\d+,-?\d+)\}",
re.search(r"static const glyph_t %s_g\[\] = \{(.*?)\};" % name, header, re.S).group(1))]
m = re.search(r"static const font_t %s = \{(\d+),(\d+)," % name.upper(), header)
fonts[short] = {"ascent": int(m.group(1)), "height": int(m.group(2)), "g": g,
"px": base64.b64encode(px).decode()}
images = json.loads((ROOT / "tools" / "editor" / "images.json").read_text())
conf = (ROOT / "card" / "sampleboot.conf").read_text()
splashes = {n: "data:image/png;base64," + base64.b64encode((ROOT / "card" / f"splash-{n}.png").read_bytes()).decode()
for n in ("dark", "light")}
logo = (ROOT / "docs" / "images" / "logo-light.svg").read_text()
logo = logo[logo.index("<svg"):].replace('width="100%" height="100%" ', 'role="img" aria-label="SampleBoot: one card, every OS" ', 1)
page = (ROOT / "tools" / "editor" / "editor.html").read_text()
page = page.replace("/*FONTS*/null", json.dumps(fonts, separators=(",", ":")))
page = page.replace("/*IMAGES*/null", json.dumps(images, separators=(",", ":")))
page = page.replace("/*SPLASHES*/null", json.dumps(splashes))
page = page.replace("<!--LOGO-->", logo)
page = page.replace('/*CONF*/""', json.dumps(conf))
out = ROOT / "tools" / "theme-editor.html"
out.write_text(page)
print(f"{out} ({len(page) // 1024} KB)")
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.