How are italic sidebearings calculated?

After a bit of playing around, it seems that the slanted side lines shown in the editor always run through the point (0, xheight/2) and (advance width, xheight/2), at the italic angle. The sidebearings shown are the extrema when measured horizontally against these straights.

Is this description complete and correct?

Is there any official documentation for this? Or something in the API?

As a maker of add-ons, can I safely assume that this will never change?

Thanks!

Yes, half of the x-height is used:

This is alluded to in the Handbook in the aligning section:

If the italic angle is not zero, instead of the left sidebearing, an imaginary vertical line crossing the slanted LSB at half x-height is used. In that case, the origin point is where this line crosses the baseline.

Note that a font may not have an x-height metric. I am unsure what the best value is then. That might also depend on your plugins use case.

1 Like

It will either use the slant height or if that is not set, it uses it uses half the x-height. It will back slant the outlines and measures the bounding box on it.