.WOFF2
Web Open Font Format 2.0
Introduction
WOFF2 is a compressed wrapper for TrueType and OpenType fonts, made for the web and
published as a W3C Recommendation in 2018. It holds the same tables as the original
font, compressed together with Brotli, and stores the glyph outlines in a transformed
form that compresses better. A WOFF2 file is typically much smaller than the font it
came from, and every current browser loads it through CSS @font-face.
The earlier WOFF 1.0, .woff, compressed each table separately with
zlib.
Software
Structure
A WOFF2 file is big-endian. It begins with a 48-byte header: the signature
wOF2, the version of the original font, the total length, the number of
tables, the size the font will have once decoded, the size of the compressed data, a
version number, and the location of optional metadata and private data. A table
directory follows, written compactly: one flags byte that usually names a known table
tag, then lengths stored as variable-length numbers. Then comes a single Brotli stream
holding every table, followed by the optional extended metadata, which is compressed
XML, and private data.
0HeaderwOF2, flavour, lengths, table count, version48 bytes48Table directory a flags byte and lengths for each tablevaries…Compressed font data every table in one Brotli streamvaries…Extended metadata, private dataoptional