# realscripts when sups are not defined

Many OpenType fonts, both free and commercial, have superiors for only 1, 2, and 3 and do not define the sups feature.

I want to use the superiors in files with no more than three footnotes. At first, I thought it would suffice to define the sups feature, as in this example, with red superiors for comparison:

% compile with lualatex
\documentclass{article}
\usepackage{filecontents,fontspec,realscripts,xcolor}
\usepackage[paperwidth=180pt,paperheight=150pt,margin=10pt]{geometry}
\begin{filecontents*}{pagella.fea}
languagesystem DFLT dflt;
languagesystem latn dflt;

feature sups {
sub \one by \one.superior;
sub \one.prop by \one.superior;
sub \one.oldstyle by \one.superior;
sub \one.taboldstyle by \one.superior;
sub \two by \two.superior;
sub \two.prop by \two.superior;
sub \two.oldstyle by \two.superior;
sub \two.taboldstyle by \two.superior;
sub \three by \three.superior;
sub \three.prop by \three.superior;
sub \three.oldstyle by \three.superior;
sub \three.taboldstyle by \three.superior;
} sups;
\end{filecontents*}
\setmainfont{TeX Gyre Pagella}[FeatureFile={pagella.fea}]
\pagestyle{empty}
\newcommand{\red}[1]{\textcolor{red}{#1}}
\begin{document}
There\footnote{Note.} \red{¹} are\footnote{Note.} \red{²}
far\footnote{Note.} \red{³} too\footnote{Note.} many\footnote{Note.}
footnotes\footnote{Note.}  in\footnote{Note.} this\footnote{Note.}
little\footnote{Note.}  sentence.\footnote{Note.}
\end{document}


But the result looks like this:

Then I added the following line to the preamble:

\renewcommand\footnotemarkfont{\addfontfeature{RawFeature={+sups}}}


Now, footnotes are marked with real superiors, but the superiors are reduced in size and their height raised:

I’ve tried reading the code of realscripts but can’t make heads or tails of it. Is there a way around the problem?

In realscript there is a test for the sups property. This fails and so realscript falls back to "fakesuperscript", which is implemented by using a smaller font size. So you should redefine \fakesuperscript:

\documentclass{article}
\usepackage{filecontents,fontspec}
\usepackage{realscripts}
\usepackage{xcolor}
\renewcommand\fakesuperscript[1]{#1}

\usepackage[paperwidth=180pt,paperheight=150pt,margin=10pt]{geometry}

\setmainfont{TeX Gyre Pagella}[FeatureFile={pagella.fea}]
\pagestyle{empty}
\newcommand{\red}[1]{\textcolor{red}{#1}}
\begin{document}

There\footnote{Note.} \red{¹} are\footnote{Note.} \red{²}
far\footnote{Note.} \red{³} too\footnote{Note.} many\footnote{Note.}
footnotes\footnote{Note.}  in\footnote{Note.} this\footnote{Note.}
little\footnote{Note.}  sentence.\footnote{Note.}
\end{document}


Naturally this means that the other superscripts will be too large and not raised ;-).

# Edit

Imho there is a bug either in fontspec or luaotfload: The FeatureFile-option creates a correspondent extended lua/luc-file which contains the information that sups is available, but either luaotfload or fontspec checks only the "normal" luc-file. This needs more investigation.

# Edit 2

I think it is a fontspec bug/missing feature. With luaotfload alone I can test for the sups feature without problems:

\documentclass{article}

\font\test="TeXGyrePagella:mode=node;script=latn;language=DFLT;+tlig;+trep;featurefile=pagella.fea;+sups;"

\font\testb="TeXGyrePagella:mode=node;script=latn;language=DFLT;+tlig;+trep;"

\begin{document}

\test test123 \directlua{if luaotfload.aux.provides_feature(font.current(),"latn","DFLT","sups")
then
tex.print("true")
else
tex.print("false")
end}

\testb test123 \directlua{if luaotfload.aux.provides_feature(font.current(),"latn","DFLT","sups")
then
tex.print("true")
else
tex.print("false")
end}
\end{document}


• @WillRobertson: Could you look at this? – Ulrike Fischer Mar 27 '15 at 13:11
• Thanks for the work-around and even more for the explanations! I love this site: bugs are found and fixed, and packages are enhanced much more quickly than would be possible without it. – Thérèse Mar 27 '15 at 14:33
• @UlrikeFischer — it looks like I don't receive these notifications if I don't log in for a long time :) Just saw your comment by chance. I'm not sure if there's much I can do in fontspec in the short term, but I'll keep this in mind, thanks. – Will Robertson Jun 18 '15 at 3:14

This is not at all a replacement for @UlrikeFischer’s excellent answer, but only a supplement for those who use luatex and need more than the three aesthetically pleasing footnote marks supplied.

In the case of TeX Gyre Pagella, one can either use Michael Sharpe’s TeXGyrePagellaX (in TeX Live), or borrow a complete set of real superiors from FPL Neu:

\documentclass{article}
\usepackage{fontspec,realscripts}
\setmainfont{TeX Gyre Pagella}
\newfontface\suppl{FPLNeu-Regular}
\renewcommand\footnotemarkfont{\suppl}
\begin{document}
There\footnote{Note.} are\footnote{Note.} far\footnote{Note.}
too\footnote{Note.} many\footnote{Note.} footnotes\footnote{Note.}
in\footnote{Note.} this\footnote{Note.} little\footnote{Note.}
sentence.\footnote{Note.}
\end{document}


In most cases, however, one won’t have an alternate cut of the same typeface from which to borrow missing glyphs, or the alternate cut won’t match perfectly. But a font with few superiors may have a complete set of numerators, and they may be visually indistinguishable from the superiors. One can test that by inspecting the output of this snippet:

{\addfontfeatures{VerticalPosition=Numerator}1}¹


If the numerators look the same as the superiors, \directlua{...} can press them into the service of realscripts:

\documentclass{article}
\usepackage{fontspec,realscripts}
% the sups feature, already defined, includes only 1–3, so we add to it:
\directlua{
name = "sups",
type = "substitution",
data = {
four = "four.numerator",
five = "five.numerator",
six = "six.numerator",
seven = "seven.numerator",
eight = "eight.numerator",
nine = "nine.numerator",
zero = "zero.numerator",
},
}
}
\setmainfont{Bembo Book MT Pro}[
Numbers={OldStyle,Proportional},
Style=Alternate]
% the sups feature in Bembo Book replaces only the default figures,
% so we turn off other choices for the footnote marks::
% to make the demonstration compact:
\usepackage[paperwidth=180pt,paperheight=90pt,margin=10pt]{geometry}
\usepackage[para]{footmisc}
\begin{document}