How to determine which component defines the LSB and RSB

In Python or ObjC, looking at a layer that contains components, what is a reliable and elegant way to determine which of them defines the LSB (and which one the RSB), if at all? In the example below, the correct answer would be: “The LSB depends on zero.percent.high.” (I am aware that the sidebearings might not be identical but changes will be reflected 1:1).

Thanks!

Do you need the actual side-bearing value or the component that is actually occupying the space?

There is no build in function to do that. You need to decompose the components, keep track of what node came from what component. And the fine the leftmost and rightmost node.

Or get the bezierpath from each component and check if it’s bounds coincides with the bounds of the full layer.

Sorry, should have described the actual situation.

The scenario is: The LSB (or RSB) of a particular glyph just got changed. Which other glyphs are immediately affected, and how?

“Which glyphs” is easy: Those glyphs that contain the glyph that was just modified.

But, how are these glyph affected?

  • (1) Without auto alignment, anything can happen to the sidebearing(s) of the dependant.
  • With auto alignment, either (2) the sidebearing of the dependant glyph is changed exactly by the same amount or (3) not changed at all.

Is that correct?

How can we determine whether it’s 1, 2 or 3?

Number 1 is easy. just check if the glyph is auto aligned.
2 and 3 should be doable, too. It depends if the component is positioned by attaching to an anchor or if it is a base glyph. The former case should not change the spacing at all but the later will.

1 Like