WIP: Fix bracket glyph components self-referencing after roundtrip. #679
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently there is an asymmetry in the implementation of alternating glyph shapes between UFO and glyphs.app that results in roundtripping resulting in glyphs that reference themselves as a component. This self-referencing can then lead to recursion errors.
UFO handles alternating glyphs shapes by including the alternative glyph as a standalone glyph in its own right, found in the glif table. GSUB rules are then implemented to make the base glyph swap out for the alternate glyph when the correct conditions are met.
Glyphs handles alternating glyph shapes using the bracket trick, which instead stores the alternate glyph, not as a different glyph, but as a "bracket" layer of the base glyph.
As a result, if you have an alternate glyph that has its base glyph as a referenced component in a UFO, running
ufo2glyphs
combines the base glyph and alternate glyph into a single glyph and you get a self referencing glyph that Glyphs.app cannot display. On the return trip,glyphs2ufo
does not unpack and separate these self referencing glyphs into their base and alternate glyph components correctly; instead creating glifs for the alternate glyphs that reference themselves as a component.This fix is to fix the 2nd problem: allowing
glyphs2ufo
to correctly unpack the base and alternate glyphs correctly so the resulting UFO after a round trip isn't broken.