Hi,
I stumbled upon a few things I don’t understand regarding the behaviour of GSLayer objects. Maybe you can enlighten me …
For context: I want to know a layer’s sidebearings with and without components. Therefore, I read out LSB & RSB, then copy the layer to remove all GSComponent shapes and then read out the LSB & RSB again. Similar to this:
lsbWithComp = layer.LSB
layerCopy = copy.copy(layer)
if layer.shapes:
layer.shapes = [s for s in layer.shapes if not isinstance(s, GSComponent)]
lsbWithoutComp = layer.LSB
While doing this, I found a few things that I think are not desired behaviour:
#1 For some layers, LSB etc. have the wrong value – even before modifying anything. Two layers with the same contents (a component and a path) show the same LSB in the interface but when I read them out in Python, they are different (layer 1 LSB: 100; layer 2 LSB 0).
#2 When I delete the components programmatically, the sidebearings do not change.
Edit: This can be achieved with GSLayer.updateMetrics()
.
#3 When I read out layer.bounds as an alternative, it’s values do change. However, the values are
- slightly off (e.g. 0.002177422795121231 instead of 0.0)
- not the values one would expect: for the “m” shown above, origin.x is 0 which is indeed the origin of the component – but the paths inside the component only start at x = 100.
Is it me? Any suggestions? Of course one could iterate over all paths and find the min/max of their bounds – but shouldn’t my solution work as well?
Thanks!