pub struct GlyphMetricRecords<'a> {
pub(crate) metrics: &'a [LongMetric],
pub(crate) bearings: &'a [BigEndian<i16>],
}Expand description
Unvaried per-glyph records from HMTX/hmtx or VMTX/vmtx.
Both tables hold the same records, so one type reads either, and which direction it describes is fixed when it is read.
Obtain these through TableProvider::h_glyph_metric_records or
TableProvider::v_glyph_metric_records. Uppercase tables are selected
independently of the outlines, with the original tables used if they are
absent.
Nothing here depends on a location, so every location shares one parse.
Fields§
§metrics: &'a [LongMetric]§bearings: &'a [BigEndian<i16>]Bare side bearings after the last long metric.
Implementations§
Source§impl<'a> GlyphMetricRecords<'a>
impl<'a> GlyphMetricRecords<'a>
Sourcefn run<'o, V: 'o>(
&self,
num_glyphs: u32,
convert: impl Fn(F48Dot16) -> V,
glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>,
)
fn run<'o, V: 'o>( &self, num_glyphs: u32, convert: impl Fn(F48Dot16) -> V, glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>, )
Writes the table’s value for each glyph.
A stored advance is a u16, so this needs neither the saturating sum
nor the lower bound of run_varied.
Sourcefn run_varied<'o, V: 'o>(
&self,
num_glyphs: u32,
delta: impl Fn(GlyphId) -> F48Dot16,
convert: impl Fn(F48Dot16) -> V,
glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>,
)
fn run_varied<'o, V: 'o>( &self, num_glyphs: u32, delta: impl Fn(GlyphId) -> F48Dot16, convert: impl Fn(F48Dot16) -> V, glyphs: impl Iterator<Item = (GlyphId, &'o mut V)>, )
Writes each glyph’s advance with delta applied.
delta is settled before the run, leaving only the branches that turn
on the glyph. The sum saturates rather than wrapping, and is clamped
to zero before conversion or scaling.
Glyphs beyond the end of the font measure zero here, as they do unvaried.
Sourcepub(crate) fn stated_advance(&self, num_glyphs: u32, glyph: GlyphId) -> F48Dot16
pub(crate) fn stated_advance(&self, num_glyphs: u32, glyph: GlyphId) -> F48Dot16
Returns the advance the table states for glyph, before any location.
A glyph past the end of the font advances by nothing. The last record covers every glyph after it, and clamping the index rather than falling back on a failed lookup keeps that bound provable, so a run compiles without a branch per glyph.
self.metrics is never empty here: a caller settles that font before
the run starts.
Sourcepub(crate) fn stated_side_bearing(&self, glyph: GlyphId) -> Option<F48Dot16>
pub(crate) fn stated_side_bearing(&self, glyph: GlyphId) -> Option<F48Dot16>
Returns the side bearing stated for glyph, including the bare
bearings following the last long metric.
Source§impl<'a> GlyphMetricRecords<'a>
impl<'a> GlyphMetricRecords<'a>
pub(crate) fn read_horizontal( tables: &(impl TableProvider<'a> + ?Sized), ) -> Result<Self, ReadError>
pub(crate) fn read_vertical( tables: &(impl TableProvider<'a> + ?Sized), ) -> Result<Self, ReadError>
Sourcepub fn long_metrics(&self) -> &'a [LongMetric]
pub fn long_metrics(&self) -> &'a [LongMetric]
Returns the paired advance and side-bearing records.
Sourcepub fn side_bearings(&self) -> &'a [BigEndian<i16>]
pub fn side_bearings(&self) -> &'a [BigEndian<i16>]
Returns the side bearings after the last long metric record.
Sourcepub fn advance(&self, glyph: GlyphId) -> Option<u16>
pub fn advance(&self, glyph: GlyphId) -> Option<u16>
Returns the unvaried advance, repeating the last record when needed. This does not check the font’s glyph count.
Sourcepub fn side_bearing(&self, glyph: GlyphId) -> Option<i16>
pub fn side_bearing(&self, glyph: GlyphId) -> Option<i16>
Returns the unvaried leading side bearing for a glyph.
Trait Implementations§
Source§impl<'a> Clone for GlyphMetricRecords<'a>
impl<'a> Clone for GlyphMetricRecords<'a>
Source§fn clone(&self) -> GlyphMetricRecords<'a>
fn clone(&self) -> GlyphMetricRecords<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more