-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
UIAll things user interface relatedAll things user interface relatedenhancementNew feature or requestNew feature or requestlambda-rsIssues pertaining to the core frameworkIssues pertaining to the core framework
Description
Overview
Add signed distance field (SDF) font rendering for resolution-independent text
that stays crisp at any scale.
Current State
No response
Scope
Goals:
- Generate SDF from font glyphs
- SDF shader for rendering
- Support arbitrary scaling without blur
- Smooth edges at all sizes
Non-Goals:
- Multi-channel SDF (MSDF)
- Precomputed SDF fonts
Proposed API
pub struct SdfGlyphAtlas {
texture: Texture,
spread: f32, // SDF spread in pixels
}
impl SdfGlyphAtlas {
pub fn new(gpu: &Gpu, size: u32, spread: f32) -> Self;
pub fn get_or_insert(&mut self, font: &Font, char: char) -> &GlyphUV;
}
pub struct SdfTextRenderer {
// uses SDF-specific shader
}
impl SdfTextRenderer {
pub fn new(render_context: &mut RenderContext, atlas: &SdfGlyphAtlas) -> Self;
pub fn draw(
&mut self,
layout: &TextLayout,
position: [f32; 2],
color: [f32; 4],
scale: f32,
) -> Vec<RenderCommand>;
}Acceptance Criteria
- SDF generation from rasterized glyphs
- Text scales smoothly without pixelation
- Sharp edges at small and large sizes
- Comparable visual quality to raster at 1x scale
- Example showing text at multiple scales
Affected Crates
lambda-rs
Notes
- SDF spread affects quality vs texture size
- Fragment shader does smoothstep on distance
Metadata
Metadata
Assignees
Labels
UIAll things user interface relatedAll things user interface relatedenhancementNew feature or requestNew feature or requestlambda-rsIssues pertaining to the core frameworkIssues pertaining to the core framework