Documentation
¶
Overview ¶
Package woff2 packs TrueType and CFF-flavored OpenType fonts into WOFF2 (W3C WOFF File Format 2.0), the web font format browsers load with FontFace.
glyf and loca are stored with the WOFF2 glyf transform (the decoder rebuilds both from separated point, flag and instruction streams), every other table passes through, and the whole table stream is Brotli-compressed. The Brotli encoder is left out of builds tagged bdf_noconv; Encode then returns ErrNotAvailable and callers keep the plain sfnt.
Index ¶
Constants ¶
const MaxRatio = 100
MaxRatio is the largest ratio of the table stream to the WOFF2 file that decoders accept (kMaxPlausibleCompressionRatio of the reference decoder, which browsers use).
Variables ¶
var ErrDecodeNotAvailable = errors.New("woff2: decoder not available in this build")
ErrDecodeNotAvailable is returned by Decode when the Brotli decoder is not compiled in (builds tagged bdf_noconv).
var ErrImplausible = errors.New("woff2: the font compresses more than decoders accept")
ErrImplausible is returned by Encode for a font that compresses more than MaxRatio times: a few glyphs left of a large font, whose tables are mostly zeros. Decoders take such a file for a decompression bomb and reject it, so the caller keeps the plain sfnt, which is as small once its part is deflated.
var ErrNotAvailable = errors.New("woff2: encoder not available in this build")
ErrNotAvailable is returned by Encode when the Brotli encoder is not compiled in.
var ErrTooLarge = errors.New("woff2: the tables of the font are too large")
ErrTooLarge is returned by Decode for a font whose tables are larger than 256 MiB together.
Functions ¶
func Decode ¶
Decode unpacks a WOFF2 font into an sfnt font (TrueType or CFF-flavored OpenType), rebuilding the transformed glyf, loca and hmtx tables. Font collections are not supported.
Types ¶
This section is empty.