import GlyphsApp
Glyphs.clearLog()
font = Glyphs.font
selectedLayers = font.selectedLayers
current_master = font.selectedFontMaster
if not current_master:
print("Error: No master is selected.")
exit()
current_master_id = current_master.id
processedGlyphs = []
axis_to_map = "axis_name_1"
layer_to_map_to = "layer_name_1"
selected_glyphs = set(layer.parent for layer in selectedLayers if layer.components and any(c.selected for c in layer.components))
for glyph in selected_glyphs:
print(f"Processing glyph: {glyph.name}")
for component in glyph.layers[current_master_id].components:
if component.selected and component.smartComponentValues is not None:
originalGlyph = font.glyphs[component.name]
if originalGlyph and originalGlyph.smartComponentAxes:
print(f" - Processing smart component source: {originalGlyph.name}")
axis_id_to_map = None
for axis in originalGlyph.smartComponentAxes:
if axis.name == axis_to_map:
axis_id_to_map = axis.id
break
if axis_id_to_map:
for layer in originalGlyph.layers:
if layer.name == layer_to_map_to:
if "smartComponentPoleMapping" not in layer.userData:
layer.userData["smartComponentPoleMapping"] = {}
layer.userData["smartComponentPoleMapping"][axis_id_to_map] = 2 # Maximum
print(f" - Applied MAX pole for axis '{axis_to_map}' to layer '{layer_to_map_to}' in '{originalGlyph.name}'")
processedGlyphs.append(originalGlyph.name)
break
if processedGlyphs:
be = "are" if len(set(processedGlyphs)) > 1 else "is"
print(f"\nPole mapping applied to source glyphs of selected smart components in {current_master.name} of: {', '.join(sorted(list(set(layer.parent.name for layer in selectedLayers if layer.master.id == current_master_id and any(c.selected for c in layer.components)))))}")
else:
print(f"No selected smart components found in the master '{current_master.name}'.")
I have been trying to pole-map the smart components’ axis with a python script, showed above. (Ticking the check box on the smart component settings)
What I tried to do with the script above is:
- On the selected font & master & selected component on selected layer(current layer)
- Finding the layer (layer_to_map_to = “layer_name_1”)
- When the layer was found, ticking the axis for the layer’s pole-mapping (axis_to_map = “axis_name_1”) as a Max(= 2)
There is no errors happened when running the script, however, there is no change on the ticking the pole-mapping box.
I wonder if I missed something.
Thank you in advance