While debugging some problems with the STIX Two fonts, I discovered what I think are two bugs in the following modules:
@<Attach subscript OpenType math kerning@> @<Attach superscript OpenType math kerning@>
First, they don't reset cur_size before calling fetch(), which means they implicitly assume that the script font is the same size as the nucleus.
Second (and I rather suspect you're aware of this), the only cases that are handled are those where the script consists of a single character (math_type = math_char), which means that, for example, $P_j$ and $P_{jj}$ will be kerned differently. It also means that, for example, changing $P_j$ to $P_{\,j}$ causes the subscript to jump by more than two thinmuskips to the right.
Enclosed for consideration is a patch that addresses both of these problems along with a some sample files using STIX Two and Cambria showing the patch at work. I hope this is more or less self-explanatory. If you need further documentation or would like me to submit the patch in a different form, please let me know.
BTW, this doesn't fix all of the kerning problems in STIX Two; the rest will have to be addressed in the font itself.
Anonymous
I have applied the patch in the TeX Live: revision 55737.