pub struct GlyfTable<'a> { /* private fields */ }Expand description
Implementations§
Source§impl<'a> GlyfTable<'a>
impl<'a> GlyfTable<'a>
Sourcepub fn subset(&self, glyph_ids: &[u16]) -> Result<SubsetGlyf<'a>, ParseError>
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>
impl<'a> GlyfTable<'a>
pub fn new(records: Vec<GlyfRecord<'a>>) -> Result<Self, ParseError>
Sourcepub fn num_glyphs(&self) -> u16
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.
pub fn records(&self) -> &[GlyfRecord<'a>]
pub fn records_mut(&mut self) -> &mut [GlyfRecord<'a>]
pub fn push(&mut self, record: GlyfRecord<'a>) -> Result<(), ParseError>
Sourcepub fn get_parsed_glyph(
&mut self,
glyph_index: u16,
) -> Result<&Glyph<'a>, ParseError>
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> OutlineBuilder for GlyfTable<'a>
impl<'a> OutlineBuilder for GlyfTable<'a>
Source§impl<'b> ReadBinaryDep for GlyfTable<'b>
impl<'b> ReadBinaryDep for GlyfTable<'b>
Source§impl<'a> WriteBinaryDep for GlyfTable<'a>
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>
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 Args = IndexToLocFormat
type Args = IndexToLocFormat
write_dep.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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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