Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fix bracket glyph components self-referencing after roundtrip. #679

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tomarcher101
Copy link
Contributor

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.

@schriftgestalt
Copy link
Collaborator

Glyphs 3 can handle both, bracket layers and distinct glyphs+conditions in feature code.

@tomarcher101 tomarcher101 force-pushed the fix-bracket-glyph-self-reference-error branch from e65de75 to 6b5b617 Compare April 5, 2021 12:18
@madig
Copy link
Collaborator

madig commented Apr 21, 2021

Glyphs 3 can handle both, bracket layers and distinct glyphs+conditions in feature code.

@schriftgestalt is there a tutorial for the latter? I only see the old tutorials that explain things for G2.

@schriftgestalt
Copy link
Collaborator

the new tutorial is almost finished. The syntax is explained here https://glyphsapp.com/news/glyphs-3-make-things-you-love (search for "#ifdef VARIABLE")

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.

None yet

3 participants