/// Measure a line of text `text` and with the typographic characteristics in `font`.
/// Returns the measured width and height.
Measure a line of text `text` and with the typographic characteristics in `font`.
Returns the measured width and height.
Measure a line of text ` text ` and with the typographic characteristics in ` font ` . Returns the measured width and height .
pub fn measure_text(text: &str, font: &FontDescription) -> Size {
    let scale = Scale::uniform(font.size as f32);
    let v_metrics = font.face.font.v_metrics(scale);
    let offset = rusttype::point(0.0, v_metrics.ascent);
    let g_opt = font.face.font.layout(text, scale, offset).last();
    let width = g_opt
        .map(|g| g.position().x as f32 + g.unpositioned().h_metrics().advance_width)
        .unwrap_or(0.0)
        .ceil();
    Size::new(width, font.size as Coord)
}
pub fn measure_text ( text : & str , font : & FontDescription ) -> Size { let scale = Scale :: uniform ( font . size as f32 ) ; let v_metrics = font . face . font . v_metrics ( scale ) ; let offset = rusttype :: point ( 0.0 , v_metrics . ascent ) ; let g_opt = font . face . font . layout ( text , scale , offset ) . last ( ) ; let width = g_opt . map ( | g | g . position ( ) . x as f32 + g . unpositioned ( ) . h_metrics ( ) . advance_width ) . unwrap_or ( 0.0 ) . ceil ( ) ; Size :: new ( width , font . size as Coord ) }
Measure a line of text `text` and with the typographic characteristics in `font`.
Measure a line of text ` text ` and with the typographic characteristics in ` font ` .
text
&str
font
&FontDescription