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

[fontra-workflow] add decompose-components action #1194

Closed
Tracked by #1144
justvanrossum opened this issue Mar 11, 2024 · 3 comments · Fixed by #1195
Closed
Tracked by #1144

[fontra-workflow] add decompose-components action #1194

justvanrossum opened this issue Mar 11, 2024 · 3 comments · Fixed by #1195

Comments

@justvanrossum
Copy link
Collaborator

No description provided.

@justvanrossum justvanrossum changed the title Flatten variable components [fontra-workflow] add flatten-variable-components action Mar 11, 2024
@justvanrossum justvanrossum changed the title [fontra-workflow] add flatten-variable-components action [fontra-workflow] add decompose-variable-components action Mar 11, 2024
@justvanrossum justvanrossum changed the title [fontra-workflow] add decompose-variable-components action [fontra-workflow] add decompose-components action Mar 11, 2024
@anthrotype
Copy link
Member

hey @justvanrossum, I'm working on a feature in ufo2ft that is somewhat related to this PR and wanted to ask you something. I see your DecomposeComponentsAction takes a VariableGlyph that may contain some components and instantiate it at all of its source locations and draws each source layer with the components converted to paths (or 'flattened' in your terminology -- to me, "to flatten components" means to keep them as components but with a max depth of 1, removing nested components of components, but that's not the issue).
The GlyphInstancer takes care of interpolating the various paths in case the composite glyph defines more sources than any of the components.

But what about the reverse of this? i.e. the composite glyph that you are decomposing definees fewer sources than some of its component glyphs: e.g. "edieresis" uses "e" and "dieresis" as components, all three glyphs define a Regular and Bold weight but only "e" defines an additional Medium weight where it adjustes, don't know, the thickness of the horizontal stem or whatever. I'd expect that while or immediately before decomposing "edieresis" composite glyph, an additional Medium source layer gets interpolated and inserted among "edieresis" sources.
Basically the logic goes like, you traverse the component tree rooted at the composite glyph you're about to decompose, and collect the union of all the locations that itself and any of its compoent (or components of components etc.) define sources at/for, instantiate the composite at those locations (i.e. a superset of its original source locations) and finally draw it with the components decomposed.
I don't see this kind of logic happening in fontra but maybe it is already there and can't find it because I'm not familiar with the code.

Context is googlefonts/glyphsLib#954 (I initially started fixing this in glyphsLib but later on decided to fix it in ufo2ft and also allow DesignSpace+UFOs projects to avail themselves of a more relaxed composite glyphs definition that Glyphs.app enables, whereby variable composite glyphs, on the one hand, and the component glyphs they refer to, on the other, don't need to define exactly the same set of source locations, but are allowed to define more or less and things get interpolated as needed.

@justvanrossum
Copy link
Collaborator Author

Hi Cosimo,

First off, you're right about "flatten" vs "decompose", and I started renaming:

Your other question is also keeping me busy, because I need to implement that, too... I have not yet figured out the way to compute which sources need to be inserted to make the decomposed glyph behave the same as the composed glyph. I'll keep you posted, and I'll try to understand your proposed solution.

@anthrotype
Copy link
Member

anthrotype commented Mar 11, 2024

they way I'm implementing it is, when I know I am about to decompose a composite glyph, I traverse the tree of components rooted at it and gather the set of all unique locations that I find, if any of these are not already defined for my composite glyph, I interplolate the layers and insert them as sources; only then I can proceed to decompose each of the variable glyph source layers.

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 a pull request may close this issue.

2 participants