# Test for old style numerals font feature (using fontspec)

Using XeLaTeX and fontspec, I want to test if the currently selected font has old style numerals (which I use in the main font, but not in the sans font). According to the fontspec documentation, it should be possible to test this using \fontspec_if_feature:nTF. The Open Type feature for old style numerals is called onum. So the following code should do the job:

\documentclass{minimal}

\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Numbers=OldStyle]{Linux Libertine O}
\setsansfont[]{Linux Biolinum O}

\ExplSyntaxOn
\def\testforonum{\fontspec_if_feature:nTF{onum}{yes}{no}}
\ExplSyntaxOff

\begin{document}

Test 123. Old style: \testforonum

\textsf{Test 123. Old style: \testforonum}

\end{document}


However, it says "yes" in both cases. Does anybody understand why?

-
But both fonts do have old style nums so the test is correct. If I use e.g. Arial I get a "no". If you want to test if old style nums have been activated you will probably have to inspect the list \l_fontspec_rawfeatures_sclist. –  Ulrike Fischer Feb 4 '13 at 16:29
Okay, so I apparently misunderstood the \fontspec_if_feature:nTF command. Thank you! –  MichaelF Feb 4 '13 at 16:47
@UlrikeFischer Can you add an answer? –  egreg Jun 1 '13 at 22:27

But both fonts do have old style numbers so the test is correct. If I use e.g. Arial I get a "no". If you want to test if old style numbers have been activated you will probably have to inspect the list \l_fontspec_rawfeatures_sclist