Skip to main content

measure_layout_json

Function measure_layout_json 

Source
pub fn measure_layout_json(
    rasterizer: &TextRasterizer,
    generator_json: &str,
    width: u32,
    height: u32,
    time: MediaTime,
    canvas: Option<(u32, u32)>,
) -> Result<String, MeasureError>
Expand description

Measures each node of the layout generator generator_json on a width by height picture at picture time time (crate::measure_layout).

Returns JSON { nodes }, each node in preorder as { at, border, content, overflow, lineCount, baselines } with boxes in fractions of the picture. lineCount is null for non-text nodes; baselines ({ first, last }, fractions of the picture height) is null for non-text nodes and empty text. canvas is the project canvas the generator’s pixel lengths refer to, the picture’s size when None.

§Errors

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