Adjusting kerning with LuaTeX and realscripts

The problem is that realscript itself use locally \addfontfeature. And this means that you are actually using two different fonts for the A and the superscript. It works fine if you use for both the same font features:

\documentclass{article}
\setlength\parindent{0pt}
\usepackage{fontspec}
\directlua {
  fonts.handlers.otf.addfeature {
    name = "supkern",
    type = "kern",
    data = {
      ["A"] = { ["eight.superior"] =  -180 },
    },
  }
}
\setmainfont{Linux Libertine O}


\begin{document}

{\addfontfeature{RawFeature=+sups}A8}

{\addfontfeature{RawFeature=+supkern;+sups}A8}
\end{document}

enter image description here


enter image description here

\documentclass{article}
\setlength\parindent{0pt}
\usepackage{fontspec}
\directlua {
  fonts.handlers.otf.addfeature {
    name = "supkern",
    type = "kern",
    data = {
      ["A"] = { ["eight.superior"] =  -180 },
    },
  }
}
\setmainfont{Linux Libertine O}
\usepackage{realscripts}
\showoutput
\begin{document}
A\textsuperscript{8}

A⁸


\addfontfeature{RawFeature=+supkern}A\textsuperscript{8}

A⁸
\end{document}

The version using realscripts/\textsuperscript is taking the superscript from a differemt font (or at least the same font, loaded differently) so there are no inter-letter kerns

....\TU/LinuxLibertineO(2)/m/n/10 A
....\TU/LinuxLibertineO(3)/m/n/10 ⁸

However the version using ⁸ just takes the character from the current fomnt and a kern is applied

....\TU/LinuxLibertineO(2)/m/n/10 A
....\kern -1.8
....\TU/LinuxLibertineO(2)/m/n/10 ⁸