pub fn render_text(
        &self,
        font_size: f64,
        paint: &Paint,
        pixmap: &mut Pixmap,
        position: (f64, f64),
        text: &str,
    ) {
        let scale = rusttype::Scale::uniform(font_size as f32);

        // The origin of a line of text is at the baseline (roughly where non-descending letters sit).
        // We don't want to clip the text, so we shift it down with an offset when laying it out.
        // v_metrics.ascent is the distance between the baseline and the highest edge of any glyph in
        // the font. That's enough to guarantee that there's no clipping.
        let v_metrics = self.inner.v_metrics(scale);
        let offset = rusttype::point(0.0, v_metrics.ascent);

        let glyphs: Vec<rusttype::PositionedGlyph> =
            self.inner.layout(text, scale, offset).collect();

        let mut glyph_tracer = GlyphTracer {
            path_builder: PathBuilder::new(),
            position: rusttype::point(0.0, 0.0),
        };
        for g in glyphs.iter() {
            let mut gpos = match g.pixel_bounding_box() {
                Some(bbox) => rusttype::point(bbox.min.x as f32, bbox.min.y as f32),
                None => {
                    continue;
                }
            };
            gpos.x += position.0 as f32;
            gpos.y += position.1 as f32;
            glyph_tracer.position = gpos;
            g.build_outline(&mut glyph_tracer);
        }
        if let Some(path) = glyph_tracer.path_builder.finish() {
            pixmap.fill_path(&path, paint, FillRule::Winding, Transform::identity(), None);
        }
    }
/// Renders the given text object.
Renders the given text object.
Renders the given text object .
pub fn render_text(
        &self,
        font_size: f64,
        paint: &Paint,
        pixmap: &mut Pixmap,
        position: (f64, f64),
        text: &str,
    ) {
        let scale = rusttype::Scale::uniform(font_size as f32);
        // The origin of a line of text is at the baseline (roughly where non-descending letters sit).
        // We don't want to clip the text, so we shift it down with an offset when laying it out.
        // v_metrics.ascent is the distance between the baseline and the highest edge of any glyph in
        // the font. That's enough to guarantee that there's no clipping.
        let v_metrics = self.inner.v_metrics(scale);
        let offset = rusttype::point(0.0, v_metrics.ascent);
        let glyphs: Vec<rusttype::PositionedGlyph> =
            self.inner.layout(text, scale, offset).collect();
        let mut glyph_tracer = GlyphTracer {
            path_builder: PathBuilder::new(),
            position: rusttype::point(0.0, 0.0),
        };
        for g in glyphs.iter() {
            let mut gpos = match g.pixel_bounding_box() {
                Some(bbox) => rusttype::point(bbox.min.x as f32, bbox.min.y as f32),
                None => {
                    continue;
                }
            };
            gpos.x += position.0 as f32;
            gpos.y += position.1 as f32;
            glyph_tracer.position = gpos;
            g.build_outline(&mut glyph_tracer);
        }
        if let Some(path) = glyph_tracer.path_builder.finish() {
            pixmap.fill_path(&path, paint, FillRule::Winding, Transform::identity(), None);
        }
    }
pub fn render_text ( & self , font_size : f64 , paint : & Paint , pixmap : & mut Pixmap , position : ( f64 , f64 ) , text : & str , ) { let scale = rusttype :: Scale :: uniform ( font_size as f32 ) ; // The origin of a line of text is at the baseline (roughly where non-descending letters sit). // We don't want to clip the text, so we shift it down with an offset when laying it out. // v_metrics.ascent is the distance between the baseline and the highest edge of any glyph in // the font. That's enough to guarantee that there's no clipping. let v_metrics = self . inner . v_metrics ( scale ) ; let offset = rusttype :: point ( 0.0 , v_metrics . ascent ) ; let glyphs : Vec < rusttype :: PositionedGlyph > = self . inner . layout ( text , scale , offset ) . collect ( ) ; let mut glyph_tracer = GlyphTracer { path_builder : PathBuilder :: new ( ) , position : rusttype :: point ( 0.0 , 0.0 ) , } ; for g in glyphs . iter ( ) { let mut gpos = match g . pixel_bounding_box ( ) { Some ( bbox ) => rusttype :: point ( bbox . min . x as f32 , bbox . min . y as f32 ) , None => { continue ; } } ; gpos . x += position . 0 as f32 ; gpos . y += position . 1 as f32 ; glyph_tracer . position = gpos ; g . build_outline ( & mut glyph_tracer ) ; } if let Some ( path ) = glyph_tracer . path_builder . finish ( ) { pixmap . fill_path ( & path , paint , FillRule :: Winding , Transform :: identity ( ) , None ) ; } }
Renders the given text object.
Renders the given text object .
&self
font_size
f64
paint
&Paint
pixmap
&mut Pixmap
position
(f64, f64)
text
&str