8

I'm using the realscript package to get true super- and subscripts with LuaLaTex. However I'm not pleased with kerning of superscripts with the font I'm using, Linux Libertine. I've tried to adjust the kerning manually using Lua code. However, it doesn't appear make any visible difference. Here's my code:

\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}

\begin{document}
A\textsuperscript{8}

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

And here's the output:

enter image description here

9

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

4

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 ⁸
  • What is the correct syntax to kern a .superior number and a period (or a comma) "not superior?. The following code is uncorrect: \directlua { fonts.handlers.otf.addfeature { name = "supkern", type = "kern", data = { ["one.superior"] = { ["period"] = -200 }, }, } } for the period is itself superscript... – user41063 Feb 9 at 13:16
  • And how is it possible to "automatize" this behavior for footnotes? – user41063 Feb 9 at 13:35
  • @user41063 it's better to ask new questions as question posts that way more people see tham and may answer, but if you just comment here it just pings me, I may not know, and I can't really answer here if it in't answering the original question – David Carlisle Feb 9 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.