Enum glyph_brush_layout::Layout
source · pub enum Layout<L: LineBreaker> {
SingleLine {
line_breaker: L,
h_align: HorizontalAlign,
v_align: VerticalAlign,
},
Wrap {
line_breaker: L,
h_align: HorizontalAlign,
v_align: VerticalAlign,
},
}
Expand description
Built-in GlyphPositioner
implementations.
Takes generic LineBreaker
to indicate the wrapping style.
See BuiltInLineBreaker
.
Example
let layout = Layout::default().h_align(HorizontalAlign::Right);
Variants§
SingleLine
Renders a single line from left-to-right according to the inner alignment. Hard breaking will end the line, partially hitting the width bound will end the line.
Wrap
Renders multiple lines from left-to-right according to the inner alignment. Hard breaking characters will cause advancement to another line. A characters hitting the width bound will also cause another line to start.
Implementations§
source§impl Layout<BuiltInLineBreaker>
impl Layout<BuiltInLineBreaker>
pub fn default_single_line() -> Self
pub fn default_wrap() -> Self
source§impl<L: LineBreaker> Layout<L>
impl<L: LineBreaker> Layout<L>
sourcepub fn h_align(self, h_align: HorizontalAlign) -> Self
pub fn h_align(self, h_align: HorizontalAlign) -> Self
Returns an identical Layout
but with the input h_align
sourcepub fn v_align(self, v_align: VerticalAlign) -> Self
pub fn v_align(self, v_align: VerticalAlign) -> Self
Returns an identical Layout
but with the input v_align
sourcepub fn line_breaker<L2: LineBreaker>(self, line_breaker: L2) -> Layout<L2>
pub fn line_breaker<L2: LineBreaker>(self, line_breaker: L2) -> Layout<L2>
Returns an identical Layout
but with the input line_breaker
Trait Implementations§
source§impl Default for Layout<BuiltInLineBreaker>
impl Default for Layout<BuiltInLineBreaker>
source§impl<L: LineBreaker> GlyphPositioner for Layout<L>
impl<L: LineBreaker> GlyphPositioner for Layout<L>
source§fn calculate_glyphs<'font, F: FontMap<'font>>(
&self,
font_map: &F,
geometry: &SectionGeometry,
sections: &[SectionText<'_>]
) -> Vec<(PositionedGlyph<'font>, Color, FontId)>
fn calculate_glyphs<'font, F: FontMap<'font>>(
&self,
font_map: &F,
geometry: &SectionGeometry,
sections: &[SectionText<'_>]
) -> Vec<(PositionedGlyph<'font>, Color, FontId)>
Calculate a sequence of positioned glyphs to render. Custom implementations should
return the same result when called with the same arguments to allow layout caching. Read more
source§fn bounds_rect(&self, geometry: &SectionGeometry) -> Rect<f32>
fn bounds_rect(&self, geometry: &SectionGeometry) -> Rect<f32>
Return a screen rectangle according to the requested render position and bounds
appropriate for the glyph layout. Read more