to_sfnt
The font file as the sfnt that shapers and rasterizers read (skrifa, ttf-parser, …):
a WOFF file is rebuilt with its tables decompressed; a TrueType, OpenType or collection file
is already one and comes back as it is, without a copy. A collection keeps all its fonts:
open it with the same index as read_font_at.
Checksums are neither verified nor recomputed: the table checksums are the ones the WOFF file records.
Import
Section titled “Import”Cargo feature font (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
bytes | &[u8] | The font file. |
Returns
Section titled “Returns”Result<Cow<'_, [u8]>, FontError> — The sfnt bytes, borrowed from bytes unless the file was WOFF.
Errors
Section titled “Errors”A FontError for data that is not a supported font, is truncated, or holds a WOFF table
that does not decompress to its announced size.
Examples
Section titled “Examples”Error type: FontError
Section titled “Error type: FontError”Why a font file could not be read.
