Skip to main content

measure_text

Function measure_text 

Source
pub fn measure_text(
    rasterizer: &TextRasterizer,
    text: &str,
    style: &TextStyle,
    size: RenderSize,
) -> Result<TextBounds, TextError>
Expand description

Where text in style lies on a canvas of size (TextBounds), laid out with rasterizer’s fonts as TextTextures::prepare lays it out and placed as a frame places it, without drawing it. Measured at the size a frame is drawn at, it agrees with that frame to the pixel; text laid out at another size can break its lines elsewhere.

§Errors

Returns TextError::Raster when the text host refuses the text: no fonts, or a style out of range.