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
Hi Georg,
I’m facing the same issue with another script, and can’t seem to find the answer in GlyphsSDK.
May I ask what’s the python analogue to changing masters (on the toolbar) for the selected layers in a tab? It is apparently different from setting tab.layers
Sure, but it doesn’t apply it to selected layers. If the tab contains layers different from current master (those changed from layers panel), Font.masterIndex doesn’t apply to them.
To show an example, below, some layers in the middle are different from current master, and I want to ‘reset’ only some of them:
tab.layers turns them all into ‘non-current-master layers’, and tab.text resets all layers to current master. I can’t seem to figure out how the app mixes both when you click the layers/master buttons with some selection
UPD
Ohhh I figured, Font.masterIndex does apply to actually selected layers (I was trying using a range of indices). That works for me, thanks!
That function works exactly like clicking the master icons. That means it switches the default master and all active/selected layers. All layers that have set their own master (like when selecting a different master in the layer panel or using tab.layers) will keep their masters.