pub struct GlyphMetrics<'a> {
h_metrics: &'a GlyphMetricRecords<'a>,
font: &'a Font,
global: &'a Metrics,
coords: &'a [F2Dot14],
num_glyphs: u32,
units_per_em: u16,
order: GlyphSourceOrder,
bitmap_ppem: Option<f32>,
}Expand description
Measurements of individual glyphs at one location.
Cheap to obtain, so it can be taken per query rather than held.
Fields§
§h_metrics: &'a GlyphMetricRecords<'a>§font: &'a Font§global: &'a Metrics§coords: &'a [F2Dot14]§num_glyphs: u32§units_per_em: u16§order: GlyphSourceOrder§bitmap_ppem: Option<f32>Implementations§
Source§impl<'a> GlyphMetrics<'a>
impl<'a> GlyphMetrics<'a>
Sourcepub fn scaled<S>(self, scale: S) -> ScaledGlyphMetrics<'a, 'static, S>where
S: Scale,
pub fn scaled<S>(self, scale: S) -> ScaledGlyphMetrics<'a, 'static, S>where
S: Scale,
Returns these metrics in the units scale describes.
Sourcepub fn scaled_f32(self, ppem: f32) -> ScaledGlyphMetrics<'a, 'static, ScaleF32>
pub fn scaled_f32(self, ppem: f32) -> ScaledGlyphMetrics<'a, 'static, ScaleF32>
Returns these metrics in pixels at ppem, as f32.
Sourcepub fn scaled_26dot6(
self,
ppem: f32,
) -> ScaledGlyphMetrics<'a, 'static, Scale26Dot6>
pub fn scaled_26dot6( self, ppem: f32, ) -> ScaledGlyphMetrics<'a, 'static, Scale26Dot6>
Returns these metrics in pixels at ppem, in 26.6 fixed point.
Sourcepub fn with_extents_source_order(
self,
order: GlyphSourceOrder,
) -> GlyphMetrics<'a>
pub fn with_extents_source_order( self, order: GlyphSourceOrder, ) -> GlyphMetrics<'a>
Measures ink using the sources in order.
Each source in the font is tried in turn until one provides extents
for the glyph. GlyphSourceOrder::DEFAULT tries bitmaps, then color,
then outlines.
Sourcepub fn extents_source_order(&self) -> GlyphSourceOrder
pub fn extents_source_order(&self) -> GlyphSourceOrder
Returns the order used to measure ink.
Sourcepub fn h_advance(&self, glyph: GlyphId) -> f32
pub fn h_advance(&self, glyph: GlyphId) -> f32
Returns the advance width of glyph, in font units.
See h_advance_exact for the width before
it is narrowed to f32.
Sourcepub fn h_advance_exact(&self, glyph: GlyphId) -> F48Dot16
pub fn h_advance_exact(&self, glyph: GlyphId) -> F48Dot16
Returns the exact advance width of glyph, in font units.
hmtx contains whole units and variations can add a fraction, so the
result may not be a whole number. A varied advance below zero is
clamped to zero before scaling. The caller decides how to round it.
Sourcepub fn h_advance_batched<'o, V>(
&self,
convert: impl Fn(F48Dot16) -> V,
glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>,
)where
V: 'o,
pub fn h_advance_batched<'o, V>(
&self,
convert: impl Fn(F48Dot16) -> V,
glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>,
)where
V: 'o,
Writes the advance width of each glyph to its slot, in order.
Each width passes through convert, so a caller working in another
number type writes into that type directly.
Sourcepub fn v_advance(&self, glyph: GlyphId) -> f32
pub fn v_advance(&self, glyph: GlyphId) -> f32
Returns the advance height of glyph, in font units.
See v_advance_exact for the height before
it is narrowed to f32.
Sourcepub fn v_advance_exact(&self, glyph: GlyphId) -> F48Dot16
pub fn v_advance_exact(&self, glyph: GlyphId) -> F48Dot16
Returns the exact advance height of glyph, in font units.
The height is non-negative, as stored in the font. A varied advance below zero is clamped to zero before scaling. A caller whose y axis points down must negate it.
Sourcepub fn v_advance_batched<'o, V>(
&self,
convert: impl Fn(F48Dot16) -> V,
glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>,
)where
V: 'o,
pub fn v_advance_batched<'o, V>(
&self,
convert: impl Fn(F48Dot16) -> V,
glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>,
)where
V: 'o,
Writes the advance height of each glyph to its slot, in order.
Each height passes through convert, so a caller working in another
number type writes into that type directly.
Sourcepub fn v_origin_y(&self, glyph: GlyphId) -> f32
pub fn v_origin_y(&self, glyph: GlyphId) -> f32
Returns the y coordinate of glyph’s vertical origin, in font units.
The x coordinate is half its advance width. See
v_origin_y_exact for the value before it is
narrowed to f32.
Sourcepub fn v_origin_y_exact(&self, glyph: GlyphId) -> F48Dot16
pub fn v_origin_y_exact(&self, glyph: GlyphId) -> F48Dot16
Returns the exact y coordinate of glyph’s vertical origin.
Sourcepub fn v_origin_y_batched<'o, V>(
&self,
convert: impl Fn(F48Dot16) -> V,
glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>,
)where
V: 'o,
pub fn v_origin_y_batched<'o, V>(
&self,
convert: impl Fn(F48Dot16) -> V,
glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>,
)where
V: 'o,
Writes the vertical origin of each glyph in font units to its slot.
VORG answers first, followed by the glyf top phantom point. Other
glyphs are centered in the horizontal line by their extents, or
placed on the ascender when extents are unavailable.
Sourcepub fn extents(&self, glyph: GlyphId) -> Option<GlyphExtents<f32>>
pub fn extents(&self, glyph: GlyphId) -> Option<GlyphExtents<f32>>
Returns where glyph’s ink sits, in font units.
An empty glyph has zero extents. None means the glyph is unavailable
or its extents could not be read. A bitmap is measured from the font’s
largest strike; scaled metrics use the strike for
the scale’s size.
See extents_exact for the values before they
are narrowed to f32.
Sourcepub fn extents_exact(&self, glyph: GlyphId) -> Option<GlyphExtents<F48Dot16>>
pub fn extents_exact(&self, glyph: GlyphId) -> Option<GlyphExtents<F48Dot16>>
Returns the exact extents of glyph in font units.
See extents_batched to compute several
glyphs’ extents with one choice of source for the batch.
Sourcepub fn extents_batched<'o, V>(
&self,
convert: impl Fn(Option<GlyphExtents<F48Dot16>>) -> V,
glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>,
)where
V: 'o,
pub fn extents_batched<'o, V>(
&self,
convert: impl Fn(Option<GlyphExtents<F48Dot16>>) -> V,
glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>,
)where
V: 'o,
Writes where each glyph’s ink sits to its slot, in order.
Each measurement passes through convert, so a caller working in
another number type writes into that type directly.
The sources are resolved once for the batch, because the available tables depend on the font rather than on the glyph. Each glyph then tries them in order until one provides extents.
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more