I would like to typeset a short, letter-like document using the Zapfino
font, with the following twist: I'm OK using Zapfino's "standard" (i.e., Variant 0) glyphs for lowercase letters, but I'd like to use the Variant 1 glyphs for uppercase letters. (In case you're curious, they look more "swash-y" than the Variant 0 uppercase glyphs...) To use a concrete example, I'd like to get
instead of
Note the different appearance of the uppercase letters. As of now, I can only achieve this look using the brute-force approach, viz., by defining the command \newcommand{\varone}[1]{{\fontspec[Variant=1]{Zapfino}#1}}
and then encasing each uppercase letter X
inside \varone{X}
.
I've perused the fontspec
manual and found the \newfontfeature
command on p. 55, but I can't seem to be able to figure out how to apply this method to my objective, which is to set the font variant separately for uppercase and lowercase letters. Anyone have an idea?
In case it matters, I'm running MacTeX2011 under MacOSX 10.6.8. The Zapfino font I have is the one that comes installed with the OS.
Answer, based on a minimally changed version of @AndreyVihrov's solution below:
% !TEX TS-program = xelatex
% !TEX encoding = UTF-8
\documentclass[letterpaper]{article}
\usepackage{fontspec}
\setmainfont{Zapfino}
% Prepare a separate "font" for Latin uppercase letters
\newfontfamily\upfont[Ligatures=TeX,Variant=1]{Zapfino}
\XeTeXinterchartokenstate=1
\newXeTeXintercharclass \uppercaseclass
% Assign the new XeTeX character class to all Latin uppercase letters
\makeatletter
\@tempcnta=`\A
\loop\unless\ifnum\@tempcnta>`\Z
\XeTeXcharclass \@tempcnta \uppercaseclass
\advance \@tempcnta by 1
\repeat
\makeatother
% Implement the font change
\XeTeXinterchartoks 0 \uppercaseclass = {\begingroup\upfont}
\XeTeXinterchartoks \uppercaseclass 0 = {\endgroup}
\XeTeXinterchartoks 255 \uppercaseclass = {\begingroup\upfont}
\XeTeXinterchartoks \uppercaseclass 255 = {\endgroup}
\begin{document}
Once Upon a Time, Prince Charming saw \ldots
\end{document}
\newcommand{\varone}[1]{{\addfontfeatures{Variant=1}#1}}
or, for implementing Andrey's trick,\begingroup\addfontfeatures{Variant=1}
instead of a whole\fontspec
. You can also consider to define a new font face instead of a font family.\newfontface
command of fontspec, that doesn't do all the job of looking for italic and bold face variants.