layers = Glyphs.font.glyphs['uni4F11'].layers
for layer in layers:
if layer.components:
for component in layer.components:
newlayer = layer.copy()
newlayer.width = layer.width
newlayer.name = component.name
newlayer.components.append(component.copy())
layers.append(newlayer)
only add code: components.copy() or newlayer.components.append(component.copy()), glyphs doesn’t respond, a red ICON is spinning. other codes work ok.
thanks reply:
i want to copy or move a layer’s component to another layer.
demo code:
layer = Glyphs.font.selectedLayers[0] # current layer
# add component
layer.components.append(GSComponent('dieresis'))
# add component at specific position
layer.components.append(GSComponent('dieresis', NSPoint(100, 100)))
# delete specific component
for i, component in enumerate(layer.components):
if component.componentName == 'dieresis':
del(layer.components[i])
break
# copy components from another layer
import copy
layer.components = copy.copy(anotherlayer.components)
# copy one component to another layer
layer.components.append(anotherlayer.component[0].copy())
i use smartcomponents. one layer only has one smartcomponent.
so i want to move smartcomponents in one layer to several layers.
how to do? 100000+ layers, so i want to do by scripting
thanks