3cdecfb9
Add font config design
a73x 2026-04-09 06:30
diff --git a/docs/superpowers/specs/2026-04-09-font-config-design.md b/docs/superpowers/specs/2026-04-09-font-config-design.md new file mode 100644 index 0000000..7fad75e --- /dev/null +++ b/docs/superpowers/specs/2026-04-09-font-config-design.md @@ -0,0 +1,70 @@ # Font Config Design ## Goal 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. ## Scope This change only covers font family and font size configuration. It does not change: - glyph rasterization behavior, - atlas packing, - text shader behavior, - runtime CLI or environment-variable configuration. ## Requirements - Add a dedicated config module at `src/config.zig`. - Define the configured font family as `Monaspace Argon`. - Define the configured font size in pixels in the same module. - Update font lookup to resolve the configured family directly. - Do not add fallback behavior. Startup should fail if the configured family cannot be resolved. - Replace existing hardcoded font-size and generic monospace lookup call sites with the config-backed values where they affect the normal terminal path. ## Design ### Config Module Add `src/config.zig` with compile-time constants: ```zig pub const font_family = "Monaspace Argon"; pub const font_size_px: u32 = 16; ``` This module is the single user-editable source for font defaults, analogous to `st`'s `config.h`. ### Font Lookup Change `src/font.zig` so the lookup helper queries the configured family instead of `"monospace"`. 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. ### Main Path Update `src/main.zig` so terminal startup uses `config.font_size_px` instead of a local hardcoded font size. The normal terminal path should use the configured family and size together, so comparisons against other terminals isolate the font choice cleanly. ### Tests Update existing tests that depend on the old lookup helper or hardcoded font size so they remain aligned with the new config-backed path. Tests should not assume fallback behavior exists. ## Error Handling 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. ## Risks - Test environments without `Monaspace Argon` installed may fail if they rely on live Fontconfig lookup. - A hardcoded family makes local setup stricter, but that is consistent with the requested comparison workflow. ## Validation - `zig build test --summary all` - Manual launch of `zig build run` - Visual comparison against Foot using the same configured font family and size