Skip to content
draw_layout

draw_layout

Mojo function 🡭

draw_layout

fn def draw_layout(mut canvas: Canvas, x: Float64, y: Float64, layout: TextLayout, color: Color, *, mut cache: FontCache)

Draw a prepared layout with its anchor at (x, y): what draw_text draws for the same arguments, without laying the text out again.

Under a canvas transform that is more than a translation the layout cannot be reused – the glyphs are placed through the matrix, which changes the placement the layout fixed – so this falls back to laying out through draw_text. The result is identical either way; only the saving is lost.

Args:

  • canvas (Canvas): Canvas to draw into.
  • x (Float64): Anchor x – baseline left end for LEFT alignment.
  • y (Float64): Anchor y – the first line’s baseline.
  • layout (TextLayout): A layout from prepare_text.
  • color (Color): Text color.
  • cache (FontCache): The same cache prepare_text was given.

Raises: