It would be very useful to have the ability to share components across masters. In cases similar to the mathematical letters, where bold or italic forms of regular letters are used. If we could use these forms as components as for the mathematical glyphs, then there would be no need in duplicating the decomposed glyphs across masters.
If we used components instead of duplication, changes to the italic forms in the italic master should automatically update the italic math glyphs in the regular master. If no components would be used, then we would have to manually fi the glyphs each time we make a change in any of the matching masters.
There are other scenarios as well where it would be useful, but this should be the main one.
You can do this already through scripting. There is no UI for this.
How would I do this through scripting exactly? If it is doable without too many compromises through scripting then that should likely suffice for now. I would however still request such a feature to be added without having to use scripts.
As for scripting, you would have to give a bit more information regarding how to accomplish this. A few links or a short explanation would be welcome.
Why? I am not convinced because it is highly complex to maintain and hard to debug. If you want do something that complex, it is less error-prone to maintain it through automation.
Set a component’s
parent to the desired layer. E.g.:
for c in Layer.components:
c.parent = c.glyph.layers
Wow, that is a really cool functionality! I had no idea you could reference other layers for components. Thank you!
Where exactly do I do this?
You paste this in the Macro window. Then you specify the exact layer you want (instead of for instance c.glyph.layers, which sets the first master of the glyph as the reference). Take a look at the scripting section of the Glyphs tutorials and the Python API documentation for more info.
So how would I set the code up to have layer 0 (regular) “iitalic-math” use layer 1 (italic) “i” as component?
I am trying to look into the documentation, but a direct example of this feature would likely be easier for understanding how this feature works exactly.
Using a component of a glyph in the same glyph is not possible. What you can do instead is use a script to copy the paths from one master to the other, which you can run whenever you want to ensure consistency.
For your setup, if I understand correctly, the following would work:
for layer in Font.selectedLayers:
source = layer.parent.layers
layer.shapes = source.shapes.copy()
layer.anchors = source.anchors.copy()
layer.width = source.width
layer.hints = source.hints.copy()
This copies everything from your second master to the layers you currently have selected. So make sure you are in your first master when selecting the respective glyphs.
That works fine in Glyphs, albeit in a somewhat wonky way. I have to first give all the italic math glyphs their matching regular letter form as a component in italic. Then I use the script when set to roman master and the glyphs gets the roman form in both roman and italic masters, then I run the script once more in the italic master and then both roman and italic masters correctly shows the italic shape.
On export the glyph does however “realign” themselves to their appropriate forms. Math italic A appears as “A” in roman and “A” in italic instead of showing the italic form “A” in both.
For this to work perfectly I would need some sort of code to decompose the letters on export while keeping the italic components in the roman master instead of reverting them to roman forms. If something like this can be done via scripting then the problem should be solved.
I am however not sure if it possible to decompose a set of predefined set of glyphs instead of all while also preserving their forms.
I’m afraid I’m having a tough time understanding your exact setup and what you are looking to achieve. If you want, you can send me your file and I’ll see about a script to take care of your specific use case (and, by extension, something more flexible). To decompose the components of a layer, you can simply use
layer.decomposeComponents() (you can even just add this into the code as a last line – don’t forget to indent the line to where the other ones are)
I think I had a very similar wish: being able to use components referencing to a different layer of the glyph itself, and treating it as paths to keep it compatible. Say you have 20 masters, but only 4 shapes of a ‘plus’ which gets copy-pasted across layers. Sure, a tool can do that, but putting that functionality into components would be more convenient.
Alternative idea: what if layers / masters could have more than one set of axes, reusing the same data in different variations?
It’s in short about having the ability to make certain glyphs such as punctuation marks, symbols or mathematical signs appear identical in all master where they should look the same, without having to keep duplicates in each master.
In addition to the closed outline components, it would immensely useful if the ability to share components across masters also includes open outline components such as corner, cap, and segment.