forked from reingart/pyfpdf
-
Notifications
You must be signed in to change notification settings - Fork 329
Open
Labels
Description
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
fpdf2could support.woffand.woff2font files natively, leveragingfontTools’ decompression features. Can we change theflavoron subset Options atfpdf.output? - Identify any optional dependencies that would need to be introduced:
- external
brotlipackage for WOFF2 decompression?
- external
- Evaluate whether HarfBuzz supports WOFF/WOFF2 directly.
- If not, confirm that we can safely decompress the font with
fontToolsfirst, then pass the resulting OpenType font data to HarfBuzz when text shaping is enabled.
- If not, confirm that we can safely decompress the font with
- Document any implications we need to take in account before implementing this feature.
Lucas-C