pub fn from_bytes<Data: Deref<Target = [u8]>>(data: Data, _: FontSettings) -> FontResult<Font> {
        let mut raw = RawFont::new(data)?;

        let mut glyphs = Vec::with_capacity(raw.glyf.glyphs.len());
        for glyph in &mut raw.glyf.glyphs {
            let geometry = Geometry::new(&glyph.points);
            let advance_width = if let Some(hmtx) = &raw.hmtx {
                let hmetric = hmtx.hmetrics[glyph.metrics];
                hmetric.advance_width as f32
            } else {
                0.0
            };
            let advance_height = if let Some(vmtx) = &raw.vmtx {
                let vmetric = vmtx.vmetrics[glyph.metrics];
                vmetric.advance_height as f32
            } else {
                0.0
            };
            let bounds = geometry.effective_bounds.unwrap_or(AABB::new(0.0, 0.0, 0.0, 0.0));
            glyphs.push(Glyph {
                geometry,
                width: bounds.xmax - bounds.xmin,
                height: bounds.ymax - bounds.ymin,
                advance_width,
                advance_height,
                bounds,
            });
        }

        // New line metrics.
        let horizontal_line_metrics = if let Some(hhea) = &raw.hhea {
            Some(LineMetrics::new(hhea.ascent, hhea.descent, hhea.line_gap))
        } else {
            None
        };
        let vertical_line_metrics = if let Some(vhea) = &raw.vhea {
            Some(LineMetrics::new(vhea.ascent, vhea.descent, vhea.line_gap))
        } else {
            None
        };

        Ok(Font {
            glyphs,
            char_to_glyph: raw.cmap.map.clone(),
            units_per_em: raw.head.units_per_em as f32,
            horizontal_line_metrics,
            vertical_line_metrics,
        })
    }
/// Constructs a font from an array of bytes.
Constructs a font from an array of bytes.
Constructs a font from an array of bytes .
pub fn from_bytes<Data: Deref<Target = [u8]>>(data: Data, _: FontSettings) -> FontResult<Font> {
        let mut raw = RawFont::new(data)?;
        let mut glyphs = Vec::with_capacity(raw.glyf.glyphs.len());
        for glyph in &mut raw.glyf.glyphs {
            let geometry = Geometry::new(&glyph.points);
            let advance_width = if let Some(hmtx) = &raw.hmtx {
                let hmetric = hmtx.hmetrics[glyph.metrics];
                hmetric.advance_width as f32
            } else {
                0.0
            };
            let advance_height = if let Some(vmtx) = &raw.vmtx {
                let vmetric = vmtx.vmetrics[glyph.metrics];
                vmetric.advance_height as f32
            } else {
                0.0
            };
            let bounds = geometry.effective_bounds.unwrap_or(AABB::new(0.0, 0.0, 0.0, 0.0));
            glyphs.push(Glyph {
                geometry,
                width: bounds.xmax - bounds.xmin,
                height: bounds.ymax - bounds.ymin,
                advance_width,
                advance_height,
                bounds,
            });
        }
        // New line metrics.
        let horizontal_line_metrics = if let Some(hhea) = &raw.hhea {
            Some(LineMetrics::new(hhea.ascent, hhea.descent, hhea.line_gap))
        } else {
            None
        };
        let vertical_line_metrics = if let Some(vhea) = &raw.vhea {
            Some(LineMetrics::new(vhea.ascent, vhea.descent, vhea.line_gap))
        } else {
            None
        };
        Ok(Font {
            glyphs,
            char_to_glyph: raw.cmap.map.clone(),
            units_per_em: raw.head.units_per_em as f32,
            horizontal_line_metrics,
            vertical_line_metrics,
        })
    }
pub fn from_bytes < Data : Deref < Target = [ u8 ] > > ( data : Data , _ : FontSettings ) -> FontResult < Font > { let mut raw = RawFont :: new ( data ) ? ; let mut glyphs = Vec :: with_capacity ( raw . glyf . glyphs . len ( ) ) ; for glyph in & mut raw . glyf . glyphs { let geometry = Geometry :: new ( & glyph . points ) ; let advance_width = if let Some ( hmtx ) = & raw . hmtx { let hmetric = hmtx . hmetrics [ glyph . metrics ] ; hmetric . advance_width as f32 } else { 0.0 } ; let advance_height = if let Some ( vmtx ) = & raw . vmtx { let vmetric = vmtx . vmetrics [ glyph . metrics ] ; vmetric . advance_height as f32 } else { 0.0 } ; let bounds = geometry . effective_bounds . unwrap_or ( AABB :: new ( 0.0 , 0.0 , 0.0 , 0.0 ) ) ; glyphs . push ( Glyph { geometry , width : bounds . xmax - bounds . xmin , height : bounds . ymax - bounds . ymin , advance_width , advance_height , bounds , } ) ; } // New line metrics. let horizontal_line_metrics = if let Some ( hhea ) = & raw . hhea { Some ( LineMetrics :: new ( hhea . ascent , hhea . descent , hhea . line_gap ) ) } else { None } ; let vertical_line_metrics = if let Some ( vhea ) = & raw . vhea { Some ( LineMetrics :: new ( vhea . ascent , vhea . descent , vhea . line_gap ) ) } else { None } ; Ok ( Font { glyphs , char_to_glyph : raw . cmap . map . clone ( ) , units_per_em : raw . head . units_per_em as f32 , horizontal_line_metrics , vertical_line_metrics , } ) }
Constructs a font from an array of bytes.
Constructs a font from an array of bytes .
data
FontSettings
data
FontSettings