Skip to content

Research needed: Support for WOFF and WOFF2 fonts #1646

@andersonhc

Description

@andersonhc

Description

WOFF (Web Open Font Format) and WOFF2 are web-optimized font formats that act as compressed wrappers around standard SFNT-based font tables (such as TrueType or OpenType). They are functionally equivalent to .ttf or .otf fonts once decompressed, but they use different container structures and compression algorithms—WOFF uses zlib, while WOFF2 uses Brotli compression.

fontTools already provides full read/write support for WOFF and WOFF2 files. However, to embed a font in a PDF, we need the raw, decompressed SFNT data (glyph tables, cmap, etc.) rather than the compressed web form.

Research objectives

  • Determine how fpdf2 could support .woff and .woff2 font files natively, leveraging fontTools’ decompression features. Can we change the flavor on subset Options at fpdf.output?
  • Identify any optional dependencies that would need to be introduced:
    • external brotli package for WOFF2 decompression?
  • Evaluate whether HarfBuzz supports WOFF/WOFF2 directly.
    • If not, confirm that we can safely decompress the font with fontTools first, then pass the resulting OpenType font data to HarfBuzz when text shaping is enabled.
  • Document any implications we need to take in account before implementing this feature.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions