Skip to content

Add MVAR support - #420

Open
lehni wants to merge 4 commits into
foliojs:masterfrom
lineto:feature/mvar
Open

lehni wants to merge 4 commits into
foliojs:masterfrom
lineto:feature/mvar

Conversation

@lehni

@lehni lehni commented Oct 26, 2026

Copy link
Copy Markdown
Contributor
  • Builds on Follow HarfBuzz for the font metrics, and fix vhea and empty glyphs #419, whose metrics it varies; only the last two commits are new here
  • Read the MVAR table and vary the ascent, descent, line gap, cap height, x-height and underline metrics of a variation by their deltas, whichever table each metric comes from, as HarfBuzz does
  • Pierre-Henri Toussaint wrote the MVAR support; the last commit is my follow-up
  • Tests use HarfBuzz's values for Playwrite and Recursive, two OFL fonts from HarfBuzz's test suite, and Mada

Vsevolod Volkov and others added 4 commits November 19, 2024 17:26
- Fix the vhea table structure
- Give empty glyphs zero coordinates instead of infinite ones
- Read the maxp, post and vhea versions as 16.16 version numbers
- Respect the useTypoMetrics flag for the font's ascent, descent and line gap, and add lineHeight
- Fix an undefined control box in the glyph metrics
- Use the typo metrics only when the font sets useTypoMetrics and the hhea metrics otherwise, with a positive ascent and a negative descent, as HarfBuzz does, instead of FreeType's fallbacks
- Drop lineHeight, which HarfBuzz doesn't have and clients can derive
- Expect HarfBuzz's vertical advance for Open Sans's space, which has no vmtx and doesn't set useTypoMetrics
- Add tests for the typo metrics, the vertical advance without vmtx, the vhea and maxp versions, and empty CFF glyph boxes, with HarfBuzz's values
- Read the MVAR table and compute its adjustments for a variation of the font
- Apply them to the typo ascent, descent and line gap, the cap height and the x-height
- Vary each metric by its MVAR delta whichever table it comes from, so fonts without useTypoMetrics also vary their ascent, descent and line gap, as HarfBuzz does
- Vary the underline position and thickness too
- Fall back to the ascent for the cap height without calling the metrics again, which recursed in fonts without OS/2
- Add tests with Playwrite, Recursive and Mada, with HarfBuzz's values, and one that variations don't share glyphs requested with other code points
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