pub fn measure_text(&self, text: &str, size: f64) -> (f64, f64) {
        let scale = rusttype::Scale::uniform(size as f32);
        let v_metrics = self.inner.v_metrics(scale);
        let offset = rusttype::point(0.0, v_metrics.ascent);

        let pixel_height = size.ceil();

        // Glyphs to draw for "RustType". Feel free to try other strings.
        let glyphs: Vec<rusttype::PositionedGlyph> =
            self.inner.layout(text, scale, offset).collect();

        let width = glyphs
            .iter()
            .rev()
            .map(|g| g.position().x as f32 + g.unpositioned().h_metrics().advance_width)
            .next()
            .unwrap_or(0.0)
            .ceil() as f64;

        (width, pixel_height)
    }
/// Measures the text width and height (given in pixels).
Measures the text width and height (given in pixels).
Measures the text width and height ( given in pixels ) .
pub fn measure_text(&self, text: &str, size: f64) -> (f64, f64) {
        let scale = rusttype::Scale::uniform(size as f32);
        let v_metrics = self.inner.v_metrics(scale);
        let offset = rusttype::point(0.0, v_metrics.ascent);
        let pixel_height = size.ceil();
        // Glyphs to draw for "RustType". Feel free to try other strings.
        let glyphs: Vec<rusttype::PositionedGlyph> =
            self.inner.layout(text, scale, offset).collect();
        let width = glyphs
            .iter()
            .rev()
            .map(|g| g.position().x as f32 + g.unpositioned().h_metrics().advance_width)
            .next()
            .unwrap_or(0.0)
            .ceil() as f64;
        (width, pixel_height)
    }
pub fn measure_text ( & self , text : & str , size : f64 ) -> ( f64 , f64 ) { let scale = rusttype :: Scale :: uniform ( size as f32 ) ; let v_metrics = self . inner . v_metrics ( scale ) ; let offset = rusttype :: point ( 0.0 , v_metrics . ascent ) ; let pixel_height = size . ceil ( ) ; // Glyphs to draw for "RustType". Feel free to try other strings. let glyphs : Vec < rusttype :: PositionedGlyph > = self . inner . layout ( text , scale , offset ) . collect ( ) ; let width = glyphs . iter ( ) . rev ( ) . map ( | g | g . position ( ) . x as f32 + g . unpositioned ( ) . h_metrics ( ) . advance_width ) . next ( ) . unwrap_or ( 0.0 ) . ceil ( ) as f64 ; ( width , pixel_height ) }
Measures the text width and height (given in pixels).
Measures the text width and height ( given in pixels ) .
&self
text
&str
size
f64