pub struct GlyphMetrics<'a> {
font: FontRef<'a>,
size: Size,
glyph_count: u32,
fixed_scale: FixedScaleFactor,
h_metrics: &'a [LongMetric],
default_advance_width: u16,
lsbs: &'a [BigEndian<i16>],
hvar: Option<Hvar<'a>>,
gvar: Option<Gvar<'a>>,
loca_glyf: Option<(Loca<'a>, Glyf<'a>)>,
coords: &'a [NormalizedCoord],
}
Expand description
Glyph specific metrics.
Fields§
§font: FontRef<'a>
§size: Size
§glyph_count: u32
§fixed_scale: FixedScaleFactor
§h_metrics: &'a [LongMetric]
§default_advance_width: u16
§lsbs: &'a [BigEndian<i16>]
§hvar: Option<Hvar<'a>>
§gvar: Option<Gvar<'a>>
§loca_glyf: Option<(Loca<'a>, Glyf<'a>)>
§coords: &'a [NormalizedCoord]
Implementations§
Source§impl<'a> GlyphMetrics<'a>
impl<'a> GlyphMetrics<'a>
Sourcepub fn new(
font: &FontRef<'a>,
size: Size,
location: impl Into<LocationRef<'a>>,
) -> Self
pub fn new( font: &FontRef<'a>, size: Size, location: impl Into<LocationRef<'a>>, ) -> Self
Creates new glyph metrics from the given font, size, and location in normalized variation space.
Sourcepub fn glyph_count(&self) -> u32
pub fn glyph_count(&self) -> u32
Returns the number of available glyphs in the font.
Sourcepub fn advance_width(&self, glyph_id: GlyphId) -> Option<f32>
pub fn advance_width(&self, glyph_id: GlyphId) -> Option<f32>
Returns the advance width for the specified glyph.
If normalized coordinates were provided when constructing glyph metrics and
an HVAR
table is present, applies the appropriate delta.
Returns None
if glyph_id >= self.glyph_count()
or the underlying font
data is invalid.
Sourcepub fn left_side_bearing(&self, glyph_id: GlyphId) -> Option<f32>
pub fn left_side_bearing(&self, glyph_id: GlyphId) -> Option<f32>
Returns the left side bearing for the specified glyph.
If normalized coordinates were provided when constructing glyph metrics and
an HVAR
table is present, applies the appropriate delta.
Returns None
if glyph_id >= self.glyph_count()
or the underlying font
data is invalid.
Sourcepub fn bounds(&self, glyph_id: GlyphId) -> Option<BoundingBox>
pub fn bounds(&self, glyph_id: GlyphId) -> Option<BoundingBox>
Returns the bounding box for the specified glyph.
Returns None
if glyph_id >= self.glyph_count()
, the underlying font
data is invalid.
Source§impl GlyphMetrics<'_>
impl GlyphMetrics<'_>
fn metric_deltas_from_gvar(&self, glyph_id: GlyphId) -> Option<[i32; 2]>
fn bounds_from_outline(&self, glyph_id: GlyphId) -> Option<BoundingBox>
Trait Implementations§
Source§impl<'a> Clone for GlyphMetrics<'a>
impl<'a> Clone for GlyphMetrics<'a>
Source§fn clone(&self) -> GlyphMetrics<'a>
fn clone(&self) -> GlyphMetrics<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more