Skip to main content

align_text

Function align_text 

Source
pub fn align_text(
    bounds: Rect,
    text_size: Size,
    justification: TextJustify,
) -> Rect
Expand description

Computes where text of a given size is drawn within a rectangle.

Backends use this so every backend aligns text the same way: horizontally by justification, and vertically centered when the text fits (top-aligned when it doesn’t).

§Arguments

  • bounds - The rectangle to draw within.
  • text_size - The size of the rendered text.
  • justification - The horizontal alignment.

§Returns

The rectangle the text occupies.