pub struct Cmap<'a> { /* private fields */ }Expand description
Implementations§
Source§impl<'a> Cmap<'a>
impl<'a> Cmap<'a>
Sourcepub fn parse(data: &'a [u8]) -> Result<Self, ParseError>
pub fn parse(data: &'a [u8]) -> Result<Self, ParseError>
Parse and validate the cmap header + encoding records.
§Errors
ParseError::TruncatedTable when header or records are truncated;
ParseError::InvalidGlyphFormat when the record count is
inconsistent with the table length.
Sourcepub fn records(&self) -> Vec<EncodingRecord>
pub fn records(&self) -> Vec<EncodingRecord>
The encoding records, in table order.
Sourcepub fn subtable(&self, index: usize) -> Result<CmapSubtable<'a>, ParseError>
pub fn subtable(&self, index: usize) -> Result<CmapSubtable<'a>, ParseError>
Decode the subtable referenced by record index.
§Errors
ParseError::InvalidCmapFormat for formats this parser does not
implement (2, 8, 10, 13, 14) or invalid format numbers;
ParseError::TruncatedTable / ParseError::InvalidGlyphFormat
for malformed subtables.
Sourcepub fn codepoint(&self, c: char) -> Option<GlyphId>
pub fn codepoint(&self, c: char) -> Option<GlyphId>
Map a Unicode scalar to a glyph id.
Candidates are scanned in spec-preference order (UCS-4 subtables
before BMP before platform-0 catch-alls); the first subtable that
both decodes and maps the codepoint wins. Returns None when no
Unicode subtable maps the character. Never panics: malformed or
unsupported subtables are skipped.