Summary
Currently, the engine uses a 5x7 pixel bitmap font rendered as individual rectangles. While this provides a retro aesthetic, it becomes pixelated when scaled up on high-resolution displays.
This issue tracks the investigation and potential implementation of Signed Distance Field (SDF) fonts for smooth, resolution-independent text rendering.
Background
This was identified during the UI readability investigation in Issue #113. The manual UI scaling feature addresses immediate usability concerns, but SDF fonts would provide a more polished visual experience.
Current State
- Font system:
src/engine/ui/font.zig - 5x7 bitmap glyphs stored as bit patterns
- Rendering: Each "pixel" of text is a solid rectangle drawn via RHI
- Scaling: Text scales linearly but remains blocky (intentional retro style)
Proposed Investigation
Option 1: SDF Font Rendering
- Pre-generate SDF textures from a TTF font (e.g., using msdfgen)
- Render text as textured quads with SDF shader
- Provides smooth edges at any scale with minimal texture memory
Option 2: stb_truetype Integration
- Runtime TTF parsing and rasterization
- More flexible but higher runtime cost
- Would require glyph caching system
Option 3: Hybrid Approach
- Keep bitmap font for small/retro UI elements
- Add SDF font option for larger text (titles, HUD)
- User setting to choose style
Implementation Considerations
- Shader changes: Need fragment shader for SDF rendering
- Texture atlas: Generate SDF atlas at build time or runtime
- Glyph metrics: Need proper kerning/advance data from TTF
- Memory: SDF atlas is typically 512x512 or 1024x1024
Acceptance Criteria
Related
Summary
Currently, the engine uses a 5x7 pixel bitmap font rendered as individual rectangles. While this provides a retro aesthetic, it becomes pixelated when scaled up on high-resolution displays.
This issue tracks the investigation and potential implementation of Signed Distance Field (SDF) fonts for smooth, resolution-independent text rendering.
Background
This was identified during the UI readability investigation in Issue #113. The manual UI scaling feature addresses immediate usability concerns, but SDF fonts would provide a more polished visual experience.
Current State
src/engine/ui/font.zig- 5x7 bitmap glyphs stored as bit patternsProposed Investigation
Option 1: SDF Font Rendering
Option 2: stb_truetype Integration
Option 3: Hybrid Approach
Implementation Considerations
Acceptance Criteria
Related