This is a follow up question to a previous reported font problem. Compiling the following MWE with LuaLaTeX
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{LibertinusMath-Regular.otf}[Kerning=On]
\showoutput
\begin{document}
$w_j q^j$
\end{document}
results into a strangely spaced subscript "j".

After some discussion with the font maintainer, with the LuaTeX maintainers on their mailing list and after I had read the OpenType specs, I came to the conclusion to fix the broken font metrics myself as suggested by Ulrike Fischer in her comment on my previous post and I followed the approach as decsribed in this answer.
Step 1
I changed the font such that the right bearings of "w" and "j" are positive and removed the italic corretions.
Step 2
I introduced staircase (aka MATH) kerning for the "w" in the lower right corner and for the "j" in the upper left corner like this:


After compiling the MWE with the new font, the result looks like this:

It is better, but not as good as expected. The log output is
....\mathon
....\TU/LibertinusMath-Regular.otf(1)/m/n/10
....\kern-1.2 (font) <--- This is it
....\hbox(4.944+1.568)x3.78995, shifted 2.09978, direction TLT
.....\TU/LibertinusMath-Regular.otf(1)/m/n/8
....\TU/LibertinusMath-Regular.otf(1)/m/n/10
....\kern0.36 (italic)
....\hbox(4.944+1.568)x3.78995, shifted -3.7496, direction TLT
.....\TU/LibertinusMath-Regular.otf(1)/m/n/8
....\mathoff
LuaLaTeX introduced a small negative kern but not as much as expected.
Step 3
By luck and accident, I compiled the MWE with the upper left staircase kerning of "j" being removed, e.g. I tried the MWE with a lower right kerning for "w" only. Et viola, the result is

The log output is
....\mathon
....\TU/LibertinusMath-Regular.otf(1)/m/n/10
....\kern-2.1 (font) <--- That's even better
....\hbox(4.944+1.568)x3.78995, shifted 2.09978, direction TLT
.....\TU/LibertinusMath-Regular.otf(1)/m/n/8
....\TU/LibertinusMath-Regular.otf(1)/m/n/10
....\kern0.36 (italic)
....\hbox(4.944+1.568)x3.78995, shifted -3.7496, direction TLT
.....\TU/LibertinusMath-Regular.otf(1)/m/n/8
....\mathoff
Of course I wondered why.
Step 4
After playing around with the upper left staircase kerning of "j", I found out the following:
- The closer the kerning points get to the outline of the j, the less effective the kerning gets, i.e. the visible white space becomes wider
- The closer the kerning points get to the left bearing of the j (i.e. the bounding box), the more effective the kerning gets, i.e. the visible with space becomes less
It seems that the upper left staircase kerning has an "inverted sign issue". If I only add staircase kerning points to the "w" and leave the "j" as is, the kerning seems to be as expected by the specs. However, if I add kerning points to the "j", too, the kerning is diminished. This gets worse the more accurate the kerning points follow the outline of the "j".
Question:
Is this a bug in LuaTeX, because it makes a wrong calculation, or does FontForge exports a broken font with wrong coordinates for the kerning points? At some point the sign gets wrong, but I do not know which is the component I should blame.
PS: Sorry, for the long post for such a simple question. Moreover, I gladly share my font files if someone wants to compile the MWE her- or himself. I would have posted and linked them here, too, if I had known how.