Format:WOFF (Web Open Font Format 1.0)
| Magic | 77 4F 46 46 ('wOFF') at 0 |
|---|---|
| Extensions | .woff |
| Endianness | big |
| License | fontTools MIT |
| On this wiki | Facts · Code · Notes · Topics |
W3C web font container (.woff, signature 'wOFF'): a 44-byte big-endian header and a table directory of 20-byte entries whose tables are each zlib-compressed separately (stored raw when compression does not help); decompressing the tables and rebuilding an sfnt directory gives back a TrueType/OpenType font.
Header
44 bytes: signature 'wOFF', flavor (sfnt version of the original: 00 01 00 00, 'OTTO', 'true'), length (file size), numTables (u16), reserved (u16, 0), totalSfntSize (size of the uncompressed font), majorVersion, minorVersion (u16 each), metaOffset, metaLength, metaOrigLength (XML metadata, zlib compressed), privOffset, privLength. See Fact:WOFF (Web Open Font Format 1.0)/struct/WOFFHeader.
Table directory
numTables entries of 20 bytes right after the header: tag, offset, compLength, origLength, origChecksum (the checksum of the original table, as in the sfnt directory). A table is zlib data (Format:Zlib stream) when compLength < origLength, otherwise stored uncompressed (compLength == origLength). Table data is 4-byte aligned. Entries are sorted by tag.
Compared with WOFF2
Format:WOFF2 compresses everything as one Format:Brotli stream and transforms glyf/loca; WOFF 1 is trivially convertible: inflate each table, write the sfnt table directory (searchRange, entrySelector, rangeShift as in Format:OpenType font file) and tables.
Code & repositories
- https://github.com/fonttools/fonttools @
b0fa59394498d146b73e2482ae7c17444ddea50b· license: MIT
fontTools (MIT): Python sfnt/WOFF/WOFF2 reader and writer; ttLib/sfnt.py has the sfnt, TTC and WOFF header structures and calcChecksum.
Tested on: source read, not run: source read · checked 2026-10-18; last activity 2026-10-16
Pitfalls
- A table is stored raw exactly when compLength == origLength: fontTools Lib/fontTools/ttLib/sfnt.py (b0fa593944) takes rawData as is when self.length == self.origLength (line 585), rejects a table whose compressed length is not smaller than origLength otherwise (line 593), and on writing keeps the table uncompressed when the zlib output is not shorter (line 611).
- Do not publish font files; most fonts are copyrighted.
Evidence & references
- https://github.com/fonttools/fonttools at commit b0fa59394498d146b73e2482ae7c17444ddea50b (MIT):
Lib/fontTools/ttLib/sfnt.pylines 468-496 (woffDirectoryFormat, woffDirectoryEntryFormat),calcChecksumlines 666-687 (sum of big-endian uint32 words mod 2^32, zero padded).