read_font
Reads what a font file says about itself: its family (typographic first), style, PostScript
name, weight or wght range and whether it is italic. Reads TrueType and OpenType files
(.ttf, .otf), the first font of a collection (.ttc, see read_font_at for the
others) and WOFF files; it does not interpret glyphs and does not check checksums.
WOFF2 tables are Brotli-compressed, and this crate has no Brotli decoder: a WOFF2 file is a
FontError::UnsupportedWoff2.
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<FontInfo, FontError> — The FontInfo.
Errors
Section titled “Errors”A FontError for data that is not a supported font, is truncated, or has no name table
or no family name.
Examples
Section titled “Examples”Error type: FontError
Section titled “Error type: FontError”Why a font file could not be read.
