Skip to main content

measure_text_json

Function measure_text_json 

Source
pub fn measure_text_json(
    rasterizer: &TextRasterizer,
    generator_json: &str,
    width: u32,
    height: u32,
) -> Result<String, MeasureError>
Expand description

Measures the text generator generator_json on a width by height canvas (crate::measure_text).

Returns JSON { layout, content, ink, lineCount, baselines }. Rectangles are { left, top, right, bottom } in fractions of the canvas, ink is null when the text draws nothing, and baselines is { first, last } in fractions of the canvas height.

§Errors

Returns MeasureError::Input for invalid generator JSON or an empty canvas, and MeasureError::Text for the text host’s refusal.