Skip to content

Evaluate FeatureVariations at the default location - #381

Merged
blikblum merged 1 commit into
foliojs:masterfrom
lineto:fix/feature-variations-default-location
Oct 23, 2026
Merged

blikblum merged 1 commit into
foliojs:masterfrom
lineto:fix/feature-variations-default-location

Conversation

@lehni

@lehni lehni commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A variable font with no explicit variation set builds no _variationProcessor (the non-CFF2 path returns null when no coords are applied), so OTProcessor skips FeatureVariations entirely — unlike HarfBuzz, which always evaluates them at the current location. As a result, default-location substitutions (e.g. bracket-layer / rvrn alternates whose condition set covers the default) never apply unless you explicitly instance the font.

Fix

Evaluate FeatureVariations at the normalized origin (all-zero coords) for a variable font that has no _variationProcessor, so default-location substitutions apply — matching HarfBuzz.

Tests

Adds a small subset of Archivo (OFL) as a fixture: its rvrn swaps $/¢ for bracket-layer alternates from wght 500 up, which covers the default (600). Without the fix the test yields dollar/cent; with it, dollar.BRACKET.110/cent.BRACKET.110, matching HarfBuzz.

@lehni
lehni force-pushed the fix/feature-variations-default-location branch from dd73900 to 2fda4e7 Compare October 18, 2026 16:02
@blikblum

Copy link
Copy Markdown
Member

Adds a minimal generated TTF variable-font fixture

This issue can be replicated with a non synthetic font?

@lehni

lehni commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Yes, it shows up in one of our not yet released commercial fonts, Unica77 LL Var (cousin of https://lineto.com/typefaces/unica77)

At the default location HarfBuzz substitutes 1 → one.BRACKET.varAlt01 through FeatureVariations, while fontkit kept one. We can't add that font to the repo, but it also reproduces with Archivo (OFL): its rvrn swaps $/¢ for bracket-layer alternates from wght 500 up, which covers the default (600). I'm going to replace the synthetic fixture with a small Archivo subset.

@lehni
lehni force-pushed the fix/feature-variations-default-location branch 2 times, most recently from d8a9d9a to 5236ef0 Compare October 21, 2026 22:10
@blikblum

Copy link
Copy Markdown
Member

@lehni more one conflict

- A TrueType variable font with no explicit variation set skipped FeatureVariations entirely, unlike HarfBuzz, which always evaluates them at the current location
- Evaluate them at the default location for such fonts, so default-location substitutions (e.g. bracket-layer alternates) apply
- Add a test with a subset of Archivo (OFL), whose rvrn alternates for $ and ¢ cover the default weight
@lehni
lehni force-pushed the fix/feature-variations-default-location branch from 5236ef0 to fcce96a Compare October 23, 2026 13:22
@lehni

lehni commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@blikblum Rebased onto master again.

@blikblum
blikblum merged commit 70ad3d5 into foliojs:master Oct 23, 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