Python build tools and utilities for asset conversion and analysis.
These scripts convert assets into C headers or binary formats for embedding in the firmware:
| Script | Description |
|---|---|
convert_labels.py |
Renders Chinese UI strings to 4-bit grayscale bitmap C headers (src/labels/). The core build tool — generates ~1200 pre-rendered label bitmaps. |
convert_cover.py |
Converts assets/s3cover.jpg boot splash image to a C header (src/s3cover_jpg.h) |
convert_sleeping.py |
Converts assets/sleeping.jpg sleep screen image to a C header (src/sleeping_jpg.h) |
convert_icons.py |
Converts PNG icons in assets/icons/ to C headers in src/icons/ |
convert_cangjie.py |
Converts data/cangjie5.dict.yaml to binary lookup format (assets/cangjie5.bin) |
convert_ttf_to_bin.py |
Converts TTF fonts to pre-rendered BIN format for faster loading. Supports fallback font borrowing and render-size scaling (e.g. Silver at 61px → 44px grid). Auto-rotates horizontal bracket glyphs 90° CW to synthesize missing vertical forms. Each glyph is centered both horizontally and vertically within its em-square cell. Correctly reads cmap from TTC collection files. Run with --gui for a graphical interface. |
Run python3 convert_ttf_to_bin.py --gui to launch the graphical converter. Supports EN/ZH language toggle, font preview, fallback font selection, and batch conversion. Features include:
- CJK-only font filtering — English-only fonts are automatically hidden from the font list
- Scrollable font list — Handles large font collections with a scrollable area and mouse wheel support
- Fallback glyph warning — Alerts when >50% of glyphs come from the fallback font (indicates a font reading issue)
- macOS app — Build a standalone
.appand.dmgwithbash scripts/build_mac_app.sh
| Script | Description |
|---|---|
compile_all_bins.sh |
Batch-compiles all TTF fonts to BIN using convert_ttf_to_bin.py. Handles Silver's render-size scaling automatically. |
| Script | Description |
|---|---|
analyze_labels.py |
Analyzes label image rendering for debugging |
analyze_cangjie.py |
Analyzes the Cangjie dictionary (character count, code distribution) |
check_missing_chars.py |
Checks for missing characters in font binary files |
check_vert_punct.py |
Checks vertical punctuation glyph coverage across fonts |
test_font_header.py |
Tests and validates generated font header files |
verify_bazi.py |
Verifies 八字 (Four Pillars) calculations against reference data |
All scripts auto-detect the project root directory, so they can be run from anywhere:
# From project root
python3 scripts/convert_labels.py
# Or from scripts directory
cd scripts && python3 convert_labels.py- Python 3
Pillow(PIL) — for image and font rendering- A TTF font file (default:
assets/fonts/GenYoMinTW-Regular.ttf)
