fpdf2 icon indicating copy to clipboard operation
fpdf2 copied to clipboard

Research needed: Support for WOFF and WOFF2 fonts

Open andersonhc opened this issue 3 months ago • 2 comments

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.

andersonhc avatar Oct 24 '25 18:10 andersonhc

assign this to me ,i will fix it

BharathPESU avatar Nov 01 '25 11:11 BharathPESU

@BharathPESU I just assigned it to you. Let us know if you have any question

andersonhc avatar Nov 04 '25 13:11 andersonhc