Expand description
Bundled custom fonts (DESIGN §18.4).
A project ships font files under a top-level fonts/ directory. day build stages them into
each platform’s native font location (Android res/font/, the iOS DayPieces bundle +
UIAppFonts, ArkUI rawfile, loose Resources/fonts on the desktops) and each backend
registers them at startup so Font::Custom("Family", pt) resolves by the font’s family
name, the name baked into the file’s name table (what Font Book / fontconfig report), not
its file name.
This module is the one implementation shared by the CLI (staging-time family extraction, identifier naming) and the runtimes (startup registration, family → file resolution):
parse_font_names: a minimal sfntname-table reader for.ttf/.otf/.ttc.font_dir/bundled_fonts: locate the staged font files at runtime (DAY_FONT_ROOTunderday launch, bundle-relativeResources/fontswhen packed).resolve_font_file: map a requested family name to one of the bundled files, for backends whose native API wants a file path rather than a registered family (XAML).font_ident: the identifier both the Android/ArkUI stagers and their runtimes derive from a family name ("Special Elite"→special_elite), so lookup needs no side table.
Structs§
- Font
Names - The names a font file reports for itself.
Constants§
- FONT_
EXTS - Font file extensions accepted under
fonts/.
Functions§
- bundled_
fonts - Every bundled font file (
font_dirfiltered toFONT_EXTS), sorted by file name. The list backends iterate to register the app’s fonts at startup. - font_
dir - The directory holding the app’s bundled font files at runtime:
DAY_FONT_ROOT(the project’sfonts/underday launch), then bundle-relative locations next to the executable (macOS.appResources/fonts, files staged next to a desktop binary). - font_
files_ in - The font files directly under
dir, sorted by file name (shared with the CLI’s scanner). - font_
ident - The identifier the Android / ArkUI stagers derive from a family name, and that their runtimes
re-derive to look the font up (Android
R.font.<ident>): lowercase,[a-z0-9_]only, with a leading letter enforced."Special Elite"→special_elite. - parse_
font_ names - Read the family and PostScript names from a raw font file (
.ttf,.otf, or the first face of a.ttc). A tiny sfnt reader: only the table directory and thenametable are touched, so it is safe to run on untrusted bytes (every access is bounds-checked). - resolve_
font_ file - Resolve a requested family name to the bundled font file that provides it (case-insensitive, PostScript name accepted too). For backends whose native font API takes a file path rather than a registered family name.