pub trait TextProvider: Send + Sync {
// Required method
fn rasterize_run(&self, run: &TextRun) -> Vec<RasterizedGlyph>;
// Provided methods
fn shape_paragraph(&self, _text: &str, _px: f32) -> Option<ShapedParagraph> { ... }
fn cache_tag(&self) -> u64 { ... }
fn line_metrics(&self, px: f32) -> Option<LineMetrics> { ... }
fn measure_run(&self, run: &TextRun) -> f32 { ... }
fn register_web_font(
&self,
_family: &str,
_data: Vec<u8>,
_weight: u16,
_style: FontStyle,
) -> Result<bool> { ... }
}Expand description
Text provider interface. Implementations convert a TextRun into positioned glyph masks.
Required Methods§
fn rasterize_run(&self, run: &TextRun) -> Vec<RasterizedGlyph>
Provided Methods§
Sourcefn shape_paragraph(&self, _text: &str, _px: f32) -> Option<ShapedParagraph>
fn shape_paragraph(&self, _text: &str, _px: f32) -> Option<ShapedParagraph>
Optional paragraph shaping hook for advanced wrappers.
Implementors that can expose Harfbuzz/cosmic-text shaping results should
return glyphs with cluster indices and advances. The default implementation
returns None, in which case callers must fall back to approximate methods.
Sourcefn cache_tag(&self) -> u64
fn cache_tag(&self) -> u64
Optional cache tag to distinguish providers in text caches. The default implementation returns 0, which is sufficient when a single provider is used with a given PassManager.
fn line_metrics(&self, px: f32) -> Option<LineMetrics>
Sourcefn measure_run(&self, run: &TextRun) -> f32
fn measure_run(&self, run: &TextRun) -> f32
Measure the total advance width of a styled text run (in the same pixel
units as run.size). The default delegates to shape_paragraph,
ignoring weight/style/family. Providers that support multiple font faces
should override this to select the correct face.