Skip to content

[glyphs-reader] instances Axis Locations override masters' (#1866)#1964

Merged
anthrotype merged 3 commits intomainfrom
fix-1866-axis-mapping-overwrite
Apr 16, 2026
Merged

[glyphs-reader] instances Axis Locations override masters' (#1866)#1964
anthrotype merged 3 commits intomainfrom
fix-1866-axis-mapping-overwrite

Conversation

@anthrotype
Copy link
Copy Markdown
Member

@anthrotype anthrotype commented Apr 16, 2026

When a font uses Axis Location custom params on both masters and instances, an instance can legitimately redefine a master's user→design mapping. Previously add_if_new() silently dropped the instance entry if the user value was already present (from the master), producing wrong output for fonts like SUSE-Italic (ExtraBold user=800 should map to design=780, not 800).

Switch to last-wins overwrite semantics everywhere, matching glyphsLib's mapping[userLoc] = designLoc.

https://github.com/googlefonts/glyphsLib/blob/71f487f9d24e/Lib/glyphsLib/builder/axes.py#L221

https://github.com/googlefonts/glyphsLib/blob/71f487f9d24e/Lib/glyphsLib/builder/axes.py#L153

Both the master Axis Location path and the instance mapping path now use add_or_replace (with a log::warn when overwriting a different value). Removed add_any_new, no longer needed.

Rename add_instance_mappings_if_new => add_instance_mappings since it now always overwrites.

Add an integration test with a minimal .glyphs fixture modeled on SUSE-Italic that compiles end-to-end and checks the avar output.

Fixes #1866

When a font uses Axis Location custom params on both masters and instances,
an instance can legitimately redefine a master's user→design mapping.
Previously `add_if_new()` silently dropped the instance entry if the user
value was already present (from the master), producing wrong output for
fonts like SUSE-Italic (ExtraBold user=800 should map to design=780, not 800).

Switch to last-wins overwrite semantics everywhere, matching glyphsLib's
`mapping[userLoc] = designLoc`. Both the master Axis Location path and the
instance mapping path now use `add_or_replace` (with a log::warn when
overwriting a different value). Removed `add_any_new`, no longer needed.

Rename `add_instance_mappings_if_new` => `add_instance_mappings` since it
now always overwrites.

Add an integration test with a minimal .glyphs fixture modeled on
SUSE-Italic that compiles end-to-end and checks the avar output.
@anthrotype
Copy link
Copy Markdown
Member Author

The SUSE-Italic.glyphs avar table becomes identical after this change.

@anthrotype
Copy link
Copy Markdown
Member Author

oh looks like I had missed a few other broken test fixtures that don't declare their weightClass #1963

i'm gonna commit them here if you don't mind

Same issue as 2c2ad47 — Bold instances with `isBold = 1` but no
explicit `weightClass`, causing wght user-space value to default to 400.
These were missed in the first pass on #1963 because I didn't run
the full test suite...
Copy link
Copy Markdown
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, a couple of things inline :)

Comment thread glyphs-reader/src/font.rs Outdated
Comment thread resources/testdata/glyphs2/WghtVar_Instances_implied_axes.glyphs
add_or_replace now returns the previous design value when overwriting,
instead of taking axis_name/source_label strings for a log::warn.
Callers format the warning with their own context.

as per Colin's review #1964 (comment)
@anthrotype anthrotype added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit 7f631b6 Apr 16, 2026
13 checks passed
@anthrotype anthrotype deleted the fix-1866-axis-mapping-overwrite branch April 16, 2026 17:34
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.

we produce a different axis mapping

2 participants