Skip to main content

canvas_measure_text

Function canvas_measure_text 

Source
pub fn canvas_measure_text(
    size: f32,
    family: &str,
    weight: u32,
    style: u32,
    text: &str,
) -> TextMetrics
Expand description

Measure a line of text shaped with the given font parameters. Returns the shaped advance width plus ascent/descent in pixels. Pass an empty family to use the system UI font; pass 0 for weight to use the default (400).

Returns zeroes if measurement isn’t available (e.g. called outside on_frame or before the host text system is ready).