1 of 10

Fonts + Compression

TypeCon 2013: Aug 2013

Google Fonts

Raph Levien

Fil Zembowicz

Kenji Baheux

David Kuettel

2 of 10

Chrome and WOFF 2.0

  • Implemented in Chrome behind a flag
    • new flag process avoids vendor prefixes

  • Serving WOFF 2.0 on google.com/fonts:
    • dynamic previews + Early Access fonts

3 of 10

Here's what we know

  • Most important for font compression
    • small file size
    • decompression speed
  • Medium importance
    • memory / cpu usage (esp. mobile)
  • Less important
    • speed of compression

4 of 10

Problems with LZMA

  • Poorly documented
    • lacks detailed specification
    • Igor Pavlov uninterested in standards work
    • this makes security review a problem
  • Slow decompression
    • ~20-30 Mb/s … 100s of ms for large fonts

5 of 10

Alternative: Brotli

  • Large-window flate implementation called Brotli
    • improves upon a few inefficiencies of Flate, boosting compression density.

  • Under active development at Google by developers of Zopfli and WebP lossless

  • Trade some file size for faster decompression compared to LZMA

6 of 10

Brotli: differences from Flate

  1. larger window (4 MB instead of 32 kB)
  2. encoding of the literal sequence lengths (like LZ4 commands)
  3. short distance codes (like in LZMA)
  4. reuse of entropy codes
  5. 1st order entropy modeling (instead of 0th order in flate)
  6. advanced block splitting
  7. zopflication (exhaustive LZ77 search)

7 of 10

Brotli: compression density

For entire Google Fonts corpus:

note: more data coming soon to public-webfonts-wg

Target compression density: additional 6-10% improvement

Algorithm

Compressed size (bytes)

delta wrt. LZMA

LZMA

47,310,972

-

Large window (4MB) flate

55,087,534

+16%

Brotli

53,610,884

+13%

8 of 10

Brotli: decompression speed

Decompression speed is greatly increased:

note: more data coming soon to public-webfonts-wg

Not a streaming algorithm: compression is slower

Algorithm

Throughput

LZMA

20-30 MB/s

NewFlate

120-300 MB/s

9 of 10

Other benefits of Brotli

  • Currently, browsers cache compressed fonts
    • Decompression time is relevant!
  • Formal specification
    • Small delta from Flate specification
  • Simplifies container format
    • fixed entropy coder
  • Commitment from Chrome
    • includes security review

10 of 10

Timeline

Soon: more performance data

Next 6 weeks: reference implementation

Following 6 weeks: Jyrki works on specification

In parallel: Chrome adds Brotli behind a flag (for release in November)