I try to add some custom kerning to an OpenType font used with fontspec
under lualatex
. The real-world example uses the Brill
fonts, but as they are not part of TeX Live I use Libertinus
in the example below.
I want to add some kerning between specific characters with diacritics and superscript numbers. The only combination which works is the direct usage of the unicode superscript numbers. As soon as I use \textsuperscript
, which is redefined by realscripts
to use the correct figures, the extra kerning is not applied.
Is there any way to achieve what I want while using \textsuperscript
?
% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{fontspec}
% Values below are for demonstration purposes only
\directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["ī"] = {
["¹"] = 500,%
["two.sups"] = 500,%
},
["š"] = {%
["one.sups"] = 500,%
["two.sups"] = 500,%
},
},
}
}
\usepackage[defaultfeatures={RawFeature={+supkern}}]{libertinus} %Brill in real life
\usepackage{realscripts}
\begin{document}
ī\textsuperscript{12}
ī¹
ī{\addfontfeatures{VerticalPosition=Superior}2}
{\addfontfeatures{RawFeature={+supkern}}ī\addfontfeatures{VerticalPosition=Superior}12}
š\textsuperscript{2}
\end{document}