[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:
http://tug.org/mailman/htdig/xetex/2008-June/010015.html
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.
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\begin{document}
\font\test="Junicode:+hlig"
\test oo
\font\test="Junicode:-hlig"
\test oo,
\font\test="Junicode:+hlig-hlig"
\test oo, %like +hlig
\font\test="Junicode:-hlig+hlig"
\test oo, %like -hlig
123,
\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
\end{document}
--
Ulrike Fischer
More information about the XeTeX
mailing list