3cdecfb9
Add font config design
a73x 2026-04-09 06:30
Commit message
docs/superpowers/specs/2026-04-09-font-config-design.md
| Old | New | ||
|---|---|---|---|
| @@ -0,0 +1,70 @@ | |||
| 1 | # Font Config Design | ||
| 2 | |||
| 3 | ## Goal | ||
| 4 | |||
| 5 | Move terminal font selection toward an `st`-style configuration model so the active font family and pixel size live in a small source file rather than being hardcoded throughout the codebase. | ||
| 6 | |||
| 7 | ## Scope | ||
| 8 | |||
| 9 | This change only covers font family and font size configuration. | ||
| 10 | |||
| 11 | It does not change: | ||
| 12 | - glyph rasterization behavior, | ||
| 13 | - atlas packing, | ||
| 14 | - text shader behavior, | ||
| 15 | - runtime CLI or environment-variable configuration. | ||
| 16 | |||
| 17 | ## Requirements | ||
| 18 | |||
| 19 | - Add a dedicated config module at `src/config.zig`. | ||
| 20 | - Define the configured font family as `Monaspace Argon`. | ||
| 21 | - Define the configured font size in pixels in the same module. | ||
| 22 | - Update font lookup to resolve the configured family directly. | ||
| 23 | - Do not add fallback behavior. Startup should fail if the configured family cannot be resolved. | ||
| 24 | - Replace existing hardcoded font-size and generic monospace lookup call sites with the config-backed values where they affect the normal terminal path. | ||
| 25 | |||
| 26 | ## Design | ||
| 27 | |||
| 28 | ### Config Module | ||
| 29 | |||
| 30 | Add `src/config.zig` with compile-time constants: | ||
| 31 | |||
| 32 | ```zig | ||
| 33 | pub const font_family = "Monaspace Argon"; | ||
| 34 | pub const font_size_px: u32 = 16; | ||
| 35 | ``` | ||
| 36 | |||
| 37 | This module is the single user-editable source for font defaults, analogous to `st`'s `config.h`. | ||
| 38 | |||
| 39 | ### Font Lookup | ||
| 40 | |||
| 41 | Change `src/font.zig` so the lookup helper queries the configured family instead of `"monospace"`. | ||
| 42 | |||
| 43 | The lookup path remains Fontconfig-based, but the selection becomes explicit rather than generic. If Fontconfig fails to resolve the configured family, the helper returns an error and terminal startup fails. | ||
| 44 | |||
| 45 | ### Main Path | ||
| 46 | |||
| 47 | Update `src/main.zig` so terminal startup uses `config.font_size_px` instead of a local hardcoded font size. | ||
| 48 | |||
| 49 | The normal terminal path should use the configured family and size together, so comparisons against other terminals isolate the font choice cleanly. | ||
| 50 | |||
| 51 | ### Tests | ||
| 52 | |||
| 53 | Update existing tests that depend on the old lookup helper or hardcoded font size so they remain aligned with the new config-backed path. | ||
| 54 | |||
| 55 | Tests should not assume fallback behavior exists. | ||
| 56 | |||
| 57 | ## Error Handling | ||
| 58 | |||
| 59 | Failure to resolve `Monaspace Argon` is treated as configuration failure, not as a recoverable runtime condition. The process should return the existing font lookup error rather than silently substituting another family. | ||
| 60 | |||
| 61 | ## Risks | ||
| 62 | |||
| 63 | - Test environments without `Monaspace Argon` installed may fail if they rely on live Fontconfig lookup. | ||
| 64 | - A hardcoded family makes local setup stricter, but that is consistent with the requested comparison workflow. | ||
| 65 | |||
| 66 | ## Validation | ||
| 67 | |||
| 68 | - `zig build test --summary all` | ||
| 69 | - Manual launch of `zig build run` | ||
| 70 | - Visual comparison against Foot using the same configured font family and size | ||