I’ve been trying to access a GSLayer
via GSComponent.componentLayer
but the value is always None
. Any idea what could be happening?
Can you should the actual code lines?
well I just realized I don’t need it, but in case it is still helpful to you:
I’m in the middle of fixing up an old script for building circled components. some things have changed across Glyphs API versions, so there are some things that are broken and I dont have a full working script to share right now. but one of the things that has changed seems to be componentLayer:
def buildCircledGlyphs(to_build,build_from,circle_type):
for i,build_glyph in enumerate(to_build):
if not font.glyphs[build_glyph]:
new_glyph = GSGlyph(build_glyph)
font.glyphs.append(new_glyph)
new_glyph.leftMetricsKey = "=50"
new_glyph.rightMetricsKey = "=50"
for layer in new_glyph.layers:
circle_component = GSComponent(circle_type)
build_component = GSComponent(build_from[i])
circle_component.automaticAlignment = True
circle_component.locked = True
build_component.automaticAlignment = False
layer.components.append(circle_component)
layer.components.append(build_component)
layer.syncMetrics()
# the issue is here
component_layer = layer.components[1].componentLayer
maybe there is there some aspect of constructing the component and adding the metric key etc that used to work in another Glyphs 3 version and has changed recently / would prevent things from initializing or something like that? if I print layer.components[1]
it exists, and shows the right component, but the .componentLayer
doesn’t exist on that component. componentLayer is a available for existing compounds, just not the ones I’m making in this script
maybe I do need it actually.
this is the old script that worked at some point in v3:
if layer.components[1].componentLayer
returns nothing, it most likely means that the component references a glyph that is not in the font, or is otherwise not setup correctly.
if you select a component in the Edit View and run
print(Layer.selection[0].componentLayer)
you will see that it will return something.
I found the issue, thanks georg