Skip to main content

DrawTextMeasurer

Trait DrawTextMeasurer 

Source
pub trait DrawTextMeasurer {
    // Required method
    fn measure_text(&self, text: &str, style: &TextStyle) -> TextMeasurement;
}
Expand description

Font-backed measurement, injected into a crate::DrawScopeDefault by the UI layer.

This crate holds no fonts, so a draw scope cannot measure text on its own. cranpose-ui installs an implementation that forwards to the very text stack the Text composable uses, which is what keeps DrawScope::measure_text and the glyphs the renderer rasterizes in agreement. Without one installed a scope falls back to estimate_text_measurement, which is good enough for layout smoke tests and wrong for anything that has to line up with real glyphs.

Required Methods§

Source

fn measure_text(&self, text: &str, style: &TextStyle) -> TextMeasurement

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§