Skip to main content

GlyphMetricRecords

Struct GlyphMetricRecords 

Source
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>

Source

pub(crate) fn is_empty(&self) -> bool

Returns true if the table states no metrics.

Source

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.

Source

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.

Source

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.

Source

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>

Source

pub(crate) fn read_horizontal( tables: &(impl TableProvider<'a> + ?Sized), ) -> Result<Self, ReadError>

Source

pub(crate) fn read_vertical( tables: &(impl TableProvider<'a> + ?Sized), ) -> Result<Self, ReadError>

Source

pub fn long_metrics(&self) -> &'a [LongMetric]

Returns the paired advance and side-bearing records.

Source

pub fn side_bearings(&self) -> &'a [BigEndian<i16>]

Returns the side bearings after the last long metric record.

Source

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.

Source

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>

Source§

fn clone(&self) -> GlyphMetricRecords<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Default for GlyphMetricRecords<'a>

Source§

fn default() -> GlyphMetricRecords<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> From<Hmtx<'a>> for GlyphMetricRecords<'a>

Source§

fn from(table: Hmtx<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<HmtxExtended<'a>> for GlyphMetricRecords<'a>

Source§

fn from(table: HmtxExtended<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Vmtx<'a>> for GlyphMetricRecords<'a>

Source§

fn from(table: Vmtx<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<VmtxExtended<'a>> for GlyphMetricRecords<'a>

Source§

fn from(table: VmtxExtended<'a>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.