Trait glyph_brush::GlyphPositioner
source · pub trait GlyphPositioner: Hash {
fn calculate_glyphs<'font, F>(
&self,
fonts: &F,
geometry: &SectionGeometry,
sections: &[SectionText<'_>]
) -> Vec<(PositionedGlyph<'font>, [f32; 4], FontId), Global>
where
F: FontMap<'font>;
fn bounds_rect(&self, geometry: &SectionGeometry) -> Rect<f32>;
fn recalculate_glyphs<'font, F>(
&self,
previous: Cow<'_, Vec<(PositionedGlyph<'font>, [f32; 4], FontId), Global>>,
change: GlyphChange,
fonts: &F,
geometry: &SectionGeometry,
sections: &[SectionText<'_>]
) -> Vec<(PositionedGlyph<'font>, [f32; 4], FontId), Global>
where
F: FontMap<'font>,
{ ... }
}
Expand description
Logic to calculate glyph positioning using Font
,
SectionGeometry
and
SectionText
.
Required Methods
sourcefn calculate_glyphs<'font, F>(
&self,
fonts: &F,
geometry: &SectionGeometry,
sections: &[SectionText<'_>]
) -> Vec<(PositionedGlyph<'font>, [f32; 4], FontId), Global>where
F: FontMap<'font>,
fn calculate_glyphs<'font, F>(
&self,
fonts: &F,
geometry: &SectionGeometry,
sections: &[SectionText<'_>]
) -> Vec<(PositionedGlyph<'font>, [f32; 4], FontId), Global>where
F: FontMap<'font>,
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.
sourcefn 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.
Provided Methods
sourcefn recalculate_glyphs<'font, F>(
&self,
previous: Cow<'_, Vec<(PositionedGlyph<'font>, [f32; 4], FontId), Global>>,
change: GlyphChange,
fonts: &F,
geometry: &SectionGeometry,
sections: &[SectionText<'_>]
) -> Vec<(PositionedGlyph<'font>, [f32; 4], FontId), Global>where
F: FontMap<'font>,
fn recalculate_glyphs<'font, F>(
&self,
previous: Cow<'_, Vec<(PositionedGlyph<'font>, [f32; 4], FontId), Global>>,
change: GlyphChange,
fonts: &F,
geometry: &SectionGeometry,
sections: &[SectionText<'_>]
) -> Vec<(PositionedGlyph<'font>, [f32; 4], FontId), Global>where
F: FontMap<'font>,
Recalculate a glyph sequence after a change.
The default implementation simply calls calculate_glyphs
so must be implemented
to provide benefits as such benefits are spefic to the internal layout logic.