# Kerning between f and footnote mark

Adapting code from an answer by U. Fischer, I hoped this might fix a problem with the footnote marks in IM Fell, which touch a preceding f. But it doesn't. How should this be done?

\documentclass{article}
\usepackage{fontspec}

\directlua {
name = "ktest",
type = "kern",
data = {
["f"] = {
["o"] =  1000,
["1"] = 1000,
["¹"] = 1000
},
},
}
}

\setmainfont{imfellenglish}[RawFeature=+ktest]

\begin{document}

foof\footnote{barb.}.

\end{document}

UPDATE:

The realscripts package makes \textsuperscript and \footnote access superscript glyphs, but the new kerning is ignored.

\documentclass{article}
\usepackage{fontspec}
\usepackage{realscripts}

\directlua {
name = "ktest",
type = "kern",
data = {
["f"] = {
["⁵"] = 1000,
}
}
}
}

\setmainfont{ebgaramond}[RawFeature=+ktest]

\begin{document}

\noindent
f⁴\\
f⁵\\
f\textsuperscript{5}\\
f\footnote{test}\\
f\footnote{test}\\
f\footnote{test}\\
f\footnote{test}\\
f\footnote{test}

\end{document}

PS III. Not even changing the otf with fontforge works.

• I don't have the font, but imho the superscript is from a smaller font and then kerning doesn't applay. You would need real superscripts to get get kerning. Check the realscript package. – Ulrike Fischer Aug 16 '17 at 18:27
• @UlrikeFischer, thanks, I'll look at it. The font is in texlive. – Toothrot Aug 16 '17 at 18:28
• Ups. Sorry I was in the wrong texsystem. I just looked the font doesn't have +sups. So kerning won't work. – Ulrike Fischer Aug 16 '17 at 18:57
• @UlrikeFischer, I tried with ebgaramond too (and realscripts), but it still doesn't work. – Toothrot Aug 16 '17 at 20:56

The realscript will not help: In the end you will still use two different fonts -- the main font and the superscript font with the +sups open type tag.

So if you want to solve your problem with kerning you need to redefine \textsuperscript so that it directly access the superscript glyphs (the example works only for 1--5) and to get \footnote working you will also need to redefine the command that set the footnotemark -- it could have side effects as one has to remove a \nobreak. The numbers used in the example are font specific. For a general solution one need some way to access the glyphs by name.

\documentclass{article}
\usepackage{fontspec}

\directlua {
name = "ktest",
type = "kern",
data = {
["f"] = {
["one.sups"] = 1000,
[983449] = 1000,
[983450] = 1000,
[983451] = 1000,
[983452] = 1000,
}
}
}
}

\setmainfont{ebgaramond}[RawFeature=+ktest]

\begin{document}

\renewcommand\textsuperscript[1]{%
\ifcase #1
\or \symbol{983448}%one.sups
\or \symbol{983449}%two.sups
\or \symbol{983450}%three.sups
\or \symbol{983451}%four.sups
\or \symbol{983452}%five.sups
\fi}

\makeatletter
\renewcommand\@makefnmark{\textsuperscript{\@thefnmark}}

\def\@footnotemark{%
\leavevmode
\ifhmode\edef\@x@sf{\the\spacefactor}%\nobreak
\fi
\@makefnmark
\ifhmode\spacefactor\@x@sf\fi
\relax}

f\footnote{test} \\
f\footnote{test}\\
f\footnote{test}\\
f\footnote{test}\\
f\footnote{test}

f\textsuperscript{1}
f\textsuperscript{2}
f\textsuperscript{3}
f\textsuperscript{4}
f\textsuperscript{5}

\end{document}