pub struct TtfParser<'a> { /* private fields */ }Expand description
TrueType font parser.
Parses the font directory and individual tables from raw TTF data. Does not own the font data; operates on borrowed slices.
Implementations§
Source§impl<'a> TtfParser<'a>
impl<'a> TtfParser<'a>
Sourcepub fn find_table(&self, tag: TableTag) -> Option<TableEntry>
pub fn find_table(&self, tag: TableTag) -> Option<TableEntry>
Find a table by tag.
Sourcepub fn table_data(&self, entry: &TableEntry) -> Result<&'a [u8], FontError>
pub fn table_data(&self, entry: &TableEntry) -> Result<&'a [u8], FontError>
Get the raw bytes for a table.
Sourcepub fn parse_head(&self) -> Result<HeadTable, FontError>
pub fn parse_head(&self) -> Result<HeadTable, FontError>
Parse the head table.
Sourcepub fn parse_hhea(&self) -> Result<HheaTable, FontError>
pub fn parse_hhea(&self) -> Result<HheaTable, FontError>
Parse the hhea table.
Sourcepub fn parse_maxp(&self) -> Result<MaxpTable, FontError>
pub fn parse_maxp(&self) -> Result<MaxpTable, FontError>
Parse the maxp table.
Sourcepub fn char_to_glyph(&self, ch: u32) -> Result<u16, FontError>
pub fn char_to_glyph(&self, ch: u32) -> Result<u16, FontError>
Look up a glyph index from a character code using cmap table.
Supports format 4 (BMP) cmap subtable.
Sourcepub fn glyph_offset(
&self,
glyph_id: u16,
head: &HeadTable,
) -> Result<(u32, u32), FontError>
pub fn glyph_offset( &self, glyph_id: u16, head: &HeadTable, ) -> Result<(u32, u32), FontError>
Get glyph offset from loca table.
Sourcepub fn parse_glyph(&self, glyph_id: u16) -> Result<GlyphOutline, FontError>
pub fn parse_glyph(&self, glyph_id: u16) -> Result<GlyphOutline, FontError>
Parse a simple glyph outline from the glyf table.