-
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 text layout that handles line breaking, alignment, and positioning of
glyphs for a given text string.
Current State
No response
Scope
Goals:
- Single-line text layout
- Multi-line text with word wrapping
- Horizontal alignment (left, center, right)
- Vertical alignment (top, middle, bottom)
- Measure text dimensions before rendering
Non-Goals:
- Rich text (multiple fonts/styles)
- Bidirectional text
- Justification
Proposed API
pub enum TextAlign {
Left,
Center,
Right,
}
pub enum TextWrap {
None,
Word,
Character,
}
pub struct TextLayout {
glyphs: Vec<PositionedGlyph>,
bounds: [f32; 4], // x, y, width, height
}
pub struct PositionedGlyph {
pub character: char,
pub position: [f32; 2],
pub uv: GlyphUV,
}
pub struct TextLayoutBuilder {
font: Handle<Font>,
size: f32,
align: TextAlign,
wrap: TextWrap,
max_width: Option<f32>,
}
impl TextLayoutBuilder {
pub fn new(font: Handle<Font>, size: f32) -> Self;
pub fn with_align(self, align: TextAlign) -> Self;
pub fn with_wrap(self, wrap: TextWrap, max_width: f32) -> Self;
pub fn layout(self, text: &str, atlas: &mut GlyphAtlas) -> TextLayout;
}
impl TextLayout {
pub fn bounds(&self) -> [f32; 4];
pub fn glyphs(&self) -> &[PositionedGlyph];
}Acceptance Criteria
- Single line text layouts correctly
- Word wrap breaks at spaces
- Alignment positions text correctly
- Bounds calculation is accurate
- Empty string produces empty layout
Affected Crates
lambda-rs
Notes
- Kerning improves appearance (if font supports)
- Consider Unicode line breaking algorithm later
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