Skip to content

Reconstruct transformed WOFF2 glyphs when subsetting - #412

Open
snowyukitty wants to merge 6 commits into
foliojs:masterfrom
snowyukitty:fix/woff2-transformed-subset
Open

snowyukitty wants to merge 6 commits into
foliojs:masterfrom
snowyukitty:fix/woff2-transformed-subset

Conversation

@snowyukitty

@snowyukitty snowyukitty commented Oct 24, 2026 •

Copy link
Copy Markdown

Fixes #201.

Subsetting a transformed WOFF2 TrueType font currently copies transformed glyf bytes as ordinary TrueType records. The regression cases demonstrate incorrect outlines and buffer bounds errors.

Reconstruct glyph records from decoded points, contour ends, instructions and component records, remapping component IDs and writing long loca offsets. Preserve point indices used by hint programs, composite transforms and overlap flags. Native regressions cover repeated encoding, empty glyphs and variation metrics with a reproducible, original test font. A generated contourless composite also checks that stored nonzero bounds and its bearing survive the upstream empty-path box change.

The branch includes current master 6a36e34, including the 3.0.0 release and subsequent changes, through a normal merge. The four changelog entries for this unmerged fix remain under Unreleased, rather than becoming part of the already-released 3.0.0 section. Upstream's release entries and README updates are preserved. The WOFF2 production changes and fixtures are unchanged by this maintenance.

Upstream ordinary TrueType variation handling, including composite flattening, varied bearings and HVAR rounding, remains intact. Transformed WOFF2 uses its separate reconstruction path, retaining component records and hint point indices.

Transformed hmtx remains unsupported and produces an explicit error. Non-default variation subsets can differ from a reference instancer in coordinates, bounding boxes, advance/bearing metrics and component offsets; cvar adjustments are not instantiated. This does not add a general variable-font instancer.

Current validation on Linux with Node 24.18.0 after merging master 6a36e34:

  • npm run prepublish: passed.
  • npm run format:check: passed.
  • npm test: 785 passing, 7 pending, including the transformed WOFF2 subset regressions.
  • Scoped git diff --check: passed.

No dependency is added by this PR. Windows and macOS were not tested locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subset of woff2 ttf fonts with transformed glyf/loca table does not work

1 participant