[XeTeX] Fontspec: Switching off a feature

Ulrike Fischer news3 at nililand.de
Mon Mar 1 14:35:55 CET 2010

Am Sun, 28 Feb 2010 22:51:08 +0100 schrieb Florian Grammel:

> I'd need to switch off one specific fontspec-feature in some specific places, without touching the other ones and also leaving italicisation etc intact. 
> Having pairs like Historical and NoHistorical, I thought this would be straightforward:
> \documentclass[12pt]{article}
> \usepackage{fontspec}
> \setromanfont{Junicode}
> \begin{document}
> oo
> \addfontfeature{Ligatures=Historical}
> oo
> {\addfontfeature{Ligatures=NoHistorical} oo}
> oo
> \end{document} 
> Could anybody give me a hint what I'm doing wrong?

Nothing, but things are simply not so easy. \addfontfeature add
opentype tags to the font, but when the list gets longer and
contains "contradicting" settings it is not always clear (and
defined) which one will win. Jonathan has written about it here:

At second \addfontfeature adds the new tags to the right, at the end
of the list, but as the following example shows in general the first
tag wins. 

So my advice is: don't nest \addfontfeature and always surround them
with braces to limit them.

\setmainfont{Latin Modern Roman}

\test oo

\test oo, 

\test oo, %like +hlig

\test oo, %like -hlig

\addfontfeatures{Numbers=OldStyle} 123, %ok
\addfontfeatures{Numbers=Lining} 123 %ok
\addfontfeatures{Numbers=OldStyle} 123 %wrong

\font\test="Latin Modern Roman:+onum"
\test 123, onum

\font\test="Latin Modern Roman:-onum"
\test 123, not onum

\font\test="Latin Modern Roman:-onum+onum"
\test 123, not onum

\font\test="Latin Modern Roman:+onum-onum"
\test 123, onum

Ulrike Fischer 

More information about the XeTeX mailing list