GlyfTable

Struct GlyfTable 

Source
pub struct GlyfTable<'a> { /* private fields */ }
Expand description

Implementations§

Source§

impl<'a> GlyfTable<'a>

Source

pub fn subset(&self, glyph_ids: &[u16]) -> Result<SubsetGlyf<'a>, ParseError>

Returns a copy of this table that only contains the glyphs specified by glyph_ids.

Source§

impl<'a> GlyfTable<'a>

Source

pub fn new(records: Vec<GlyfRecord<'a>>) -> Result<Self, ParseError>

Source

pub fn num_glyphs(&self) -> u16

Returns the number of glyphs in this glyf table.

Returns a u16 for convenience of interacting with other parts of the code.

Source

pub fn records(&self) -> &[GlyfRecord<'a>]

Source

pub fn records_mut(&mut self) -> &mut [GlyfRecord<'a>]

Source

pub fn push(&mut self, record: GlyfRecord<'a>) -> Result<(), ParseError>

Source

pub fn get_parsed_glyph( &mut self, glyph_index: u16, ) -> Result<&Glyph<'a>, ParseError>

Returns a parsed glyph, converting GlyfRecord::Present into GlyfRecord::Parsed if necessary.

Trait Implementations§

Source§

impl<'a> Debug for GlyfTable<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> OutlineBuilder for GlyfTable<'a>

Source§

type Error = ParseError

Source§

fn visit<V: OutlineSink>( &mut self, glyph_index: u16, visitor: &mut V, ) -> Result<(), Self::Error>

Visit the glyph outlines in self.
Source§

impl<'a> PartialEq for GlyfTable<'a>

Source§

fn eq(&self, other: &GlyfTable<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'b> ReadBinaryDep for GlyfTable<'b>

Source§

type Args<'a> = &'a LocaTable<'a>

Source§

type HostType<'a> = GlyfTable<'a>

Source§

fn read_dep<'a>( ctxt: &mut ReadCtxt<'a>, loca: Self::Args<'a>, ) -> Result<Self::HostType<'a>, ParseError>

Source§

impl<'a> WriteBinaryDep for GlyfTable<'a>

Source§

fn write_dep<C: WriteContext>( ctxt: &mut C, table: GlyfTable<'a>, index_to_loc_format: IndexToLocFormat, ) -> Result<Self::Output, WriteError>

Write this glyf table into ctxt.

§A Note About Padding

On the loca table documentation at the bottom it states:

Note that the local offsets should be 32-bit aligned. Offsets which are not 32-bit aligned may seriously degrade performance of some processors.

On the Recommendations for OpenType Fonts page it states:

We recommend that local offsets should be 16-bit aligned, in both the short and long formats of this table.

On Apple’s loca documentation it says:

The glyph data is always word aligned.

Elsewhere in the Apple docs they refer to long as 32-bits, so assuming word here means 16-bits.

An issue was raised against Microsoft’s docs regarding this. Behdad Esfahbod commented:

All the requirements should be removed since 2019.

In reality, in the short format, you are forced to do 16-bit alignment because of how offsets are stored. In the long format, use alignment 1. We’ve been doing that in fonttools for years and never ever heard a complaint whatsoever.

So with this in mind we implement 16-bit alignment when index_to_loc_format is 0, and no alignment/padding otherwise.

Source§

type Output = LocaTable

The type of the value returned by write_dep.
Source§

type Args = IndexToLocFormat

The type of the arguments supplied to write_dep.
Source§

impl<'a> StructuralPartialEq for GlyfTable<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for GlyfTable<'a>

§

impl<'a> RefUnwindSafe for GlyfTable<'a>

§

impl<'a> Send for GlyfTable<'a>

§

impl<'a> Sync for GlyfTable<'a>

§

impl<'a> Unpin for GlyfTable<'a>

§

impl<'a> UnwindSafe for GlyfTable<'a>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.