Skip to content

Round HVAR advance deltas like HarfBuzz - #427

Merged
blikblum merged 1 commit into
foliojs:masterfrom
lineto:fix/hvar-advance-rounding
Oct 26, 2026
Merged

blikblum merged 1 commit into
foliojs:masterfrom
lineto:fix/hvar-advance-rounding

Conversation

@lehni

@lehni lehni commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

As found in #426: fontkit adds the HVAR delta to the advance without rounding it, so varied advances come out fractional (oe in Source Sans 3 at wght: 200 is 851.9999999999999). Writing them into hmtx truncates them, so the subset gets 851, where fontTools' instancer and HarfBuzz give 852.

  • Round the HVAR delta to whole units, as HarfBuzz does with roundf, and as fontkit already does with gvar deltas
  • The two HVAR tests in test/variations.js rounded the advance themselves; they now check the exact advance and fail without the fix

npm test passes (699 passing, 7 pending), and npm run format:check is clean.

- Round the varied advances from HVAR to whole units, as HarfBuzz does
- Subsets of fonts with set variations no longer truncate advances like 851.9999 to 851
- Make the two HVAR tests check exact advances
@blikblum
blikblum merged commit 9add590 into foliojs:master Oct 26, 2026
3 checks passed
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.

2 participants