How to properly set tab’s master?

Hi! After I insert layers to tab.layers, and try to switch master through interface, it only changes the selected layer:

How can I hook them up to the master, so they are treated together (unless layer is different)?

This is for a tweak for Change Case plugin, so I want to keep user’s layers and can’t set it through tab.text.

When you set tab.layers, each layer has the master information attached. Like when you click the master in the layer panel for each layer. If you don’t like that, you need to use the tab.text API:

string = ""
for l in Font.selectedLayers:
	char = Font.characterForGlyph_(l.parent)
	string += chr(char)
tab = Font.tabs[0]
tab.text = string

Can I ask what’s the API for clicking the Layers panel in a tab? tab.layers[ i ] = layer doesn’t seem to be allowed.

You could ask for the layers, change it and then assign it back. But that might behave unexpectedly.

To understand how it works internally, habe a look at the implementation in the python wrapper in the GlyphsSDK repo.

1 Like