pub struct OwnedFont { /* private fields */ }Expand description
An owned font buffer, validated at construction.
The allocating counterpart of FontRef: produced by SFNT validation of
an owned buffer, WOFF/WOFF2 decoding, or extraction from a collection.
Access the zero-copy view with as_font_ref.
Implementations§
Source§impl OwnedFont
impl OwnedFont
Sourcepub fn from_woff(data: &[u8]) -> Result<Self, ParseError>
pub fn from_woff(data: &[u8]) -> Result<Self, ParseError>
Decode a WOFF 1.0 container (feature woff).
§Errors
ParseError::InvalidSfnt for a bad header, table, or zlib stream.
Sourcepub fn from_woff2(data: &[u8]) -> Result<Self, ParseError>
pub fn from_woff2(data: &[u8]) -> Result<Self, ParseError>
Decode a WOFF 2.0 container, reversing the glyf/loca/hmtx transforms
(feature woff2).
§Errors
ParseError::InvalidSfnt for container errors;
ParseError::UnsupportedWoff2Transform for undefined transform
versions; ParseError::InvalidGlyphFormat for glyph-transform
inconsistencies.
Sourcepub fn from_collection(data: &[u8], index: usize) -> Result<Self, ParseError>
pub fn from_collection(data: &[u8], index: usize) -> Result<Self, ParseError>
Extract font index from a TTC collection into a standalone SFNT.
§Errors
ParseError::InvalidSfnt for a bad TTC header;
ParseError::CollectionIndexOutOfBounds when index is beyond the
declared font count.
Sourcepub fn as_font_ref(&self) -> Result<FontRef<'_>, ParseError>
pub fn as_font_ref(&self) -> Result<FontRef<'_>, ParseError>
The zero-copy view over the owned buffer.
§Errors
ParseError::InvalidSfnt — structurally impossible (the buffer was
validated at construction), kept for API symmetry with fallible
constructors.