Reversing WOFF2 Brotli Streams and Transformed TrueType Contour Streams
Why WOFF2 Requires Structural Table Reconstruction Beyond Brotli
Unlike WOFF 1.0, a WOFF2 file cannot be unpacked by simply running a generic Brotli decompressor over individual table slices. The W3C WOFF2 format concatenates all font tables into a single shared Brotli stream and applies specialized structural preprocessing to TrueType glyf and loca tables. Explicit glyph bounding boxes are omitted from simple contours, contour end-point arrays are packed into variable-length integer sub-streams, and loca offset arrays are stripped completely.
During WOFF2-to-TTF recovery, our WebAssembly decoder inflates the unified Brotli payload, parses the seven separate glyf sub-streams (nContour, nPoints, flags, glyph deltas, composite data, instructions, and bbox bitmaps), recalculates exact bounding boxes for simple and composite glyphs, rebuilds the loca index table according to head.indexToLocFormat, and normalizes all SFNT checksums.
- Uses the standalone 288 KB woff2-encoder/decompress WebAssembly decoder module.
- Reconstructs composite glyph component pointers so accented characters like Ā render identically.
- Restores omitted hmtx left-side bearings when proportional transform version 1 was applied.
- Normalizes head.checkSumAdjustment after glyf reconstruction so desktop installers never warn.