Decomposed Copy returns bounding box size as 0

I’d like to get the bounding box of a decomposed layer. To ensure, I don’t decompose the actual layer I’m working on, I copy it into another object. As soon as I do this, the bounding box does not have any width and height any more, even though the copied layer contains paths.

Here is what I tried:

layer = Glyphs.font.selectedLayers[0]
for path in layer.paths:
	print("layer:", path)
print("layer:", layer.bounds)

copiedLayer = layer.copyDecomposedLayer()
print("copied layer:", copiedLayer)

for path in copiedLayer.paths:
	print("copied layer:", path)
print("copied layer:", copiedLayer.bounds)

Is this intended behaviour?

I think I can work around this by using the bounding box of the original layer for now, but in other cases this might not be possible.

The layer needs the layer.parent to be set to compute the bounds (to get to corners and components).
So after copying do this:

copiedLayer.parent = layer.parent
1 Like

Yes, it works! :raised_hands: Thank you!