Skip to main content

height_for_width

Function height_for_width 

Source
pub fn height_for_width(
    p: &mut dyn Painter,
    style: &TextStyle,
    msg: &str,
    width: u32,
    wrap: Wrap,
    max_lines: Option<usize>,
) -> u32
Expand description

Measures the height of wrapped text for a given width, so a layout can give a label the height it needs.

§Arguments

  • p - The painter (it measures).
  • style - The font.
  • msg - The text.
  • width - The width in pixels the text will be drawn at.
  • wrap - How lines break; Wrap::None is one line per \n.
  • max_lines - The most lines, or None.

§Returns

The height in pixels: the number of lines times the line height.