pub enum ParseError {
InvalidSfnt,
UnknownTableTag(RawTag),
TruncatedTable {
tag: RawTag,
expected: usize,
got: usize,
},
InvalidCmapFormat(u16),
InvalidGlyphFormat,
UnsupportedWoff2Transform,
CollectionIndexOutOfBounds {
index: usize,
count: usize,
},
InvalidUnitsPerEm(u16),
}Expand description
The single crate-level error for all font parsing.
Variants§
InvalidSfnt
The SFNT offset table (or WOFF/WOFF2 header) is malformed: bad signature, impossible table count, or a directory entry whose offset/length pair is out of range.
UnknownTableTag(RawTag)
A four-byte tag carried a value outside the known table set, where a
known tag was required. Raw (unknown) table access is available via
crate::FontRef::table_by_tag — this variant applies to typed
lookups only.
TruncatedTable
A structure declared (or a read required) more bytes than the buffer
holds. Bounds are checked at every read; tag is the table (or
container) being read, expected the required absolute end offset,
got the bytes actually available.
Fields
InvalidCmapFormat(u16)
A cmap subtable carries a format this parser does not implement
(formats 2, 8, 10, 13, 14) or a structurally invalid format number.
Supported formats: 0, 4, 6, 12.
InvalidGlyphFormat
A glyf/loca/gvar record is structurally invalid: bad coordinate
runs, a composite component loop that exceeds the nesting cap, a loca
entry descending, or a WOFF2 glyph substream inconsistency.
UnsupportedWoff2Transform
A WOFF2 table directory entry declares a transformation version that
is not defined for its tag (e.g. transformed name), so the entry
cannot be decoded. Only glyf/loca (version 0) and hmtx (version 1)
transforms are defined by WOFF2 2.0.
CollectionIndexOutOfBounds
A collection (TTC) index beyond the number of fonts declared by the
ttcf header.
InvalidUnitsPerEm(u16)
The head table’s unitsPerEm is zero or above the OpenType maximum
of 16384.