Components from another master possible?

Is it possible to have components from one master to another? Let’s say you want to have the same minsucules in two masters, but different capitals.

This has popped up from time to time and I seem to remember there was some hacky way of doing this (components pointing to specific layers instead of just glyphs).

One case I encounter all the time is circled numbers, which I want to be the same in italics as in the Roman (unslanted), or math symbols, which some designers prefer to be unslanted in italic styles.

Not sure how to do that in the UI, but you can use this snippet to set it via Python:

c = Layer.components[0]
c.setComponentMasterId_(Font.masters[0].id)

This will set the first component of your current master (lets assume you are in the second master) to the first master component.
When you select that component after running it, it will show something like A@Regular as the component name in the gray info box. (Again, assuming the component points to glyph “A” and the first master is “Regular”)

From there you could adjust your code accordingly.

This doesn’t work for me, sadly. Does it work for you?
In this example, I set it to point to my font’s first (Thin Upright) master:

Yes, I wrote this and tested. Didn’t try in the latest 3.2 though, still in 3234.

In your screenshot it looks that it actually worked almost, just that it is setting the class item (or how that is called) instead of the actual instance. It shows what it would print if you inspect the (thin) master with a non-wrapped function.

Like:

print(Font.masters[0])
>>> <GSFontMaster "Thin" (100.0,0.0)>

Haha, I’m an idiot. I passed the master as the argument, not its ID.

yes. that’s it

Thanks a lot. Now I don’t need to wrangle numbers as smart components with italic axis just to have upright circled numbers.

The logical continuation would be to let glyphs reference themselves as components, but a different master.

With scripting, it works, but the compatibility is not given anymore, sadly:

Any chance this special case could be evaluated?

Ah wait, the export works, amazing!!

Continuing in a separate comment. This works really nicely, hats off. There are still some oddities:

The setup works in edit view, but not in the preview panel (also not when holding space bar).

Also, this trick works for glyphs where the origin layers have only paths, but not for glyphs where the origin layer has components. (like in the above screenshot)

That feature is somehow half-baked. Could you send me a test file.

I tried this again for a family where two masters are identical for the uppercase. When exporting, all my glyphs are reported as incompatible.

Do you need a test file?