XeLaTeX: How to prevent the use of subscripted and superscripted versions of Arabic numerals in the math mode?

I use the Libertinus font family in my documents. Libertinus Serif contains superscripted and subscripted versions of Arabic numerals, whereas Libertinus Math don't.

In the math mode, for some reason those glyphs are used (leading to unpleasant kerning etc etc) with anything less than \normalsize, explicitly (that is, through \small, \scriptsize, \footnotesize, and \tiny) or implicitly (for example, through ^ and _). Wrapping the superscripted/subscripted numerals in \mathrm helps as a workaround. But surely there must be a better way?

\documentclass{article}
\usepackage{unicode-math}
\setmainfont{Libertinus Serif}
\setmathfont{Libertinus Math}

\begin{document}

$1234567890^{1234567890}$

$1234567890^\mathrm{1234567890}$

\end{document}


• No “superscript digits” are used. If you compare {\footnotesize $1234567890$} and {\footnotesize 1234567890} you can see the same effect. – egreg Jun 13 '16 at 15:03
• @egreg Weird... It seems anothing smaller than \normalsize uses those glyphs... Let me rephrase the question to reflect this. – Taiki Jun 13 '16 at 15:07
• As soon as you use a font size less than 10pt, the shape of the digits in Libertinus Math changes. – egreg Jun 13 '16 at 15:23
• @egreg Not entirely accurate. With the default font size set to 12pt, \small digits, which are larger than 10pt, still use the alternative glyphs. – Taiki Jun 13 '16 at 15:28
• I wouldn't disable ssty for everything: also letters are affected. – egreg Jun 13 '16 at 16:16

Section 4.2 in the manual of unicode-math specifies that the Style=MathScript and Style=MathScriptScript are automatically applied for sizes less than the font's base size.

The Libertinus Math font happens to support these features by defining specific shapes for the digits.

You can disable this by setting a different font for the digits only by specifying a range:

\documentclass[12pt]{article}

\usepackage{ifxetex} % for the ugly workaround

\usepackage{unicode-math}
\setmainfont{Libertinus Serif}
\setmathfont{Libertinus Math}[
]
\setmathfont{Libertinus Math}[
range=0-9,
script-features={},
sscript-features={},
]
\setmathfont{Libertinus Math}[range=\int] % just for safety

% using range has unexpected consequences on \left and \right
% see http://tex.stackexchange.com/a/207554/4427
\ifxetex
\Udelcodenum.=1073741824 % reset the right delcode
fi
\begin{document}

$1234567890^{1234567890}$

$1234567890^\mathrm{1234567890}$

\end{document}


• This works perfectly, but it seems to clash with the package mathtools in handling \left. and \right. in, for example, $\left[ \frac{1}{2} \right.$. – Taiki Jun 13 '16 at 17:11
• @Taiki That, unfortunately, is a bug of unicode-math, see github.com/wspr/unicode-math/issues/351 :( You can temporarily disable the script features globally, without using a range. – egreg Jun 13 '16 at 17:16
• Oh no. :'( Thank you very much for the link, which lets me know that \setmathfont[range={\dummysymbol}]{<some suitable font>}` helps. – Taiki Jun 13 '16 at 17:21
• I added a workaround; though ugly, it works. – egreg Jun 13 '16 at 17:38