Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have some trouble setting oldstyle numbers in my document. I load the font (in this case an early palatino) and define the smallcaps font via fontspec. But the oldstyle numbers are in the smallcaps variant of this font and don't display in the main text.

\setmainfont[ Numbers={Proportional, OldStyle}, SmallCapsFont={PalmerCapsOld} ]{Palmer}
share|improve this question
    
Related to, but not quite a duplicate of Font substitution with XeLaTeX. –  J. C. Salomon Jul 12 '12 at 21:53
1  
1  
Possible duplicate of Fontspec: Palatino with small caps and old-style figures; at least Khaled Hosny’s answer covers this question. –  J. C. Salomon Jul 13 '12 at 16:19
1  
Would you please point to a description of the fonts you're using? If they are free, we can test them. –  egreg Jul 20 '12 at 8:43

2 Answers 2

What fontspec provides is syntax for enabling OpenType features. What you need is the ability to switch fonts every time numerals are displayed.

XeTeX has the XeTeXinterchartoks functionality to enable this; LuaTeX does not (at least not directly; see below).

For example, try this code:

% !TeX program = xelatex
\documentclass{article}
\XeTeXinterchartokenstate = 1
\newXeTeXintercharclass \numeralsclass
\newXeTeXintercharclass \numeralsclass
\count255=`\0
\loop\ifnum\count255<`\9
    \XeTeXcharclass \count255 \numeralsclass
    \advance\count255 by 1
\repeat

\XeTeXinterchartoks 0 \numeralsclass = {\bgroup\itshape}
\XeTeXinterchartoks 255 \numeralsclass = {\bgroup\itshape}
\XeTeXinterchartoks \numeralsclass 0 = {\egroup}
\XeTeXinterchartoks \numeralsclass 255 = {\egroup}

\begin{document}
abc 123 def456jkl789

32

`33'--44
\end{document}

This code allocates a character class for numerals, then assigns it to 0–9.

Between character class 0 (letters) or 255 (non-characters: glue, kern, math, box, etc.) and the newly-defined character class for numerals, we insert a font change (\itshape for visibility); between numerals and class 0/255 we insert \egroup to undo that font change.

You should be able to apply this to your case something like this:

\setmainfont[ Numbers={Proportional}, SmallCapsFont={PalmerCapsOld} ]{Palmer}
…
\XeTeXinterchartoks 0 \numeralsclass = {\bgroup\scshape}
\XeTeXinterchartoks \numeralsclass 0 = {\egroup}
\XeTeXinterchartoks 255 \numeralsclass = {\bgroup\scshape}
\XeTeXinterchartoks \numeralsclass 255 = {\egroup}

But… you wanted a LuaLaTeX solution.

See In LuaTex is it possible to change font/language according to the script/glyphs used? for LuaTeX code that mimics XeTeXinterchartoks. The trouble is a difference in when the code executes; if I’ve understood Manuel Pégourié-Gonnard’s comment correctly, even code like \count255 might break.

You might be better off running a regexp search on your document, to surround each run of numerals with \textsc{}.

share|improve this answer
    
Thank you so far! Your example already works in XeLaTeX, I'll try it tomorrow in luatex. Maybe I should write the author of fontspec, because it's not uncommon to have the oldstyle numbers in the smallcaps font. –  Tobias Schula Jul 12 '12 at 22:17
    
@TobiasSchula, as I explained, this is not within the bailiwick of fontspec. –  J. C. Salomon Jul 12 '12 at 22:24

Quoting Khaled Hosny’s answer to Fontspec: Palatino with small caps and old-style figures, here’s another solution:

You need a Palatino with proper OpenType support, alternatively you can use TeX Gyre Pagella (which is true Palatino by Zapf, and further opentypified by GUST) which is included in TeXlive.

\documentclass{article}
\usepackage{fontspec}

\setmainfont[Numbers=OldStyle]{TeX Gyre Pagella}

\begin{document}
Text 12345.
\end{document}
share|improve this answer
    
Yeah, I already know about the TeX Gyre Collection. However this is not what I'm looking for. The Pagella is a modification of the URW Palladio, which is designed to mimic the Adobe Palatino, which is one of the core Postscript fonts. The Palatino I intend to use is based on the cut from the 50s, it has a more calligraphic style. –  Tobias Schula Jul 18 '12 at 23:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.