The corner glyph is a wonderful function.
And we want to copy some different glyphs with corners to one glyph to make a new glyph. The following script is my test, but the corner in layer4 can’t copy right or lost.
Could you help ? We hope can copy them as we wish.
layer1 = Glyphs.font.glyphs['uni4E01'].layers[0].copy()
layer3 = Glyphs.font.glyphs['uni4E03'].layers[0].copy()
layer4 = Glyphs.font.glyphs['uni4E04'].layers[0].copy()
layer5 = Glyphs.font.glyphs['uni4E05'].layers[0].copy()
layer = Glyphs.font.glyphs['uni4E07'].layers[0]
layer.clear()
layer.hints = nil # clear() is not resetting the hints. I fixed that
layer.shapes.extend(layer5.shapes)
layer.hints.extend(layer5.hints)
layer.shapes.extend(layer4.shapes)
layer.hints.extend(layer4.hints)
layer.shapes.extend(layer1.shapes)
layer.shapes.extend(layer3.shapes)
print("done")
you don’t need to import copy if you call the copy method. The copy module would be used like this: layer1 = copy(layer2). But calling the native method is better.
When you assign the shapes and the hints from two different copies, the connection is lost. So make one copy and use it for both.
Or you could assign the glyphs as components and decompose them:
references = ("uni4E01", "uni4E03", "uni4E04", "uni4E05")
layer = Glyphs.font.glyphs["uni4E07"].layers[0]
layer.clear()
layer.hints = nil # clear() is not resetting the hints. I fixed that
for reference in references:
comp = GSComponent(reference)
comp.position = NSPoint(10, 220) # pick a position if needed
comp.automaticAlignment = False
layer.shapes.append(comp)
layer.decomposeComponents()
print("done")
from Foundation import NSPoint
references = ["uni4E01", "uni4E03", "uni4E04", "uni4E05"]
layer = Glyphs.font.glyphs["uni4E07"].layers[0]
layer.clear()
layer.hints = None # clear() is not resetting the hints. I fixed that
for reference in references:
comp = GSComponent(reference)
comp.position = NSPoint(10, 220) # pick a position if needed
comp.automaticAlignment = False
layer.shapes.append(comp)
layer.decomposeComponents()
print("done")