I really like the concept of the smart component for CKJ, so I’m trying to make some scripts for that. But there are some problems while using smartComponentPollMapping.
I wanted to change the axis values of smart components by setting smartComponentPollMapping attribute. But it didn’t work well. So I’ve consumed a lot of time that I found out that it needs ‘userData - PartSelection’ by comparing two glyphs files that the one is from changing by GUI and the one is from changing by the script. But the glyphs file from GUI contains userData, but the one from the script does not contain it.
So, I put ‘userData’ like below.
for layer in smartGlyph.layers:
userData = {}
if layer.name == 'Regular':
for axis in smart.layers:
if axis.name != 'Regular':
userData[axis.name] = 2
else:
userData = { layer.name: 2}
layer.userData['PartSelection'] = userData
for axis in smart.layers:
if layer.name == 'Regular':
layer.smartComponentPoleMapping[axis.name] = 2
if axis.name == layer.name:
layer.smartComponentPoleMapping[axis.name] = 1
But I found out another problem which is the code above does not work on running state. But if saving and reopening Glyphs again, I could figure out it works well. I want it to be effective while running Glyphs app.
I have a look at this. That the PartSelection is stored in the usedData is an implementation detail and you should not use that. Because at runtime, that value is not taken from the userdata but from the smartComponentPoleMapping.
I need to understand what you are trying to do. Could you send me that font that I can try it for myself?