# Font features selection in Xe(La)TeX

I am using the XeTeX engine in order to compile a document based on a class of my own, and the package fontspec to select the face families and features. Though this is not relevant for my question, just with the aim to be more concrete, let me say that for the sans face I am using Formata (from Adobe). This family comes in different .otf files, with the root name Formata, in such a way that the *-Regular file (and *-Light as well, this being just about weight series) includes only the "non-expert" types, small caps and text figures being included in files *-RegularSC and even another, *-RegularExpert.

I have no problem about small caps thanks to the fontspec key SmallCapsFont, but I'd like to have text figures as my default selection for numerals. Of course I have Numbers=OldStyle set in my \defaultfontfeatures, but this won't do. Is there a way that I can get to the numerals in the "expert" files without having to switch through \textsc?

Moreover, the Formata family includes a condensed face in a file *-Condensed (together with all shapes and weight series). Is there a switch to have this loaded without having to resort to fontspec's \newfontfamily or \newfontface?

Well, my priority is on the numerals-related question, but just to not open another post, I thought the latter would be appropriate here, too.

-
Are you sure Formata is by Adobe? I can't find it on their font site. Do you mean Linotype Formata? –  mrf Aug 8 '12 at 9:26
@mrf: My mistake. I have edited my post accordingly. Thanks so much for pointing this out. –  Marcos Aug 8 '12 at 9:30
Does the -RegularSC font contain all normal glyphs as well? Usually OpenType fonts contain the oldstyle digits and small caps in the same font as the regular one. The separation you describe sound more like how it used to be with Type1 fonts. Maybe they just converted those to OFT without taking too much care. If that's the case, just use Formata-RegularSC as your main font. –  mrf Aug 8 '12 at 9:32
@mrf: I'm afraid it doesn't. If it did, I would just do as you say and select the corresponding file as my UprightFont file, but I don't even have the glyphs for lowercase letters in the "expert" file. I agree about your point on the "resemblance" to Type1 fonts; it looks a lot like that. –  Marcos Aug 8 '12 at 9:38
Very odd. Looking at Linotype's web site, it looks like Formata OTF has small caps and oldstyle figures in the same font file, as it should be. I wonder what version of the font you actually have. –  mrf Aug 8 '12 at 10:01

Many tools can let you inspect the features for OTF fonts (and there's often a documentation, too).

For example, you can use otfinfo:

\$ otfinfo -f /usr/local/share/fonts/EBGaramond12-Regular.otf
c2sc    Small Capitals From Capitals
calt    Contextual Alternates
case    Case-Sensitive Forms
ccmp    Glyph Composition/Decomposition
cv01    <unknown feature>
cv02    <unknown feature>
cv03    <unknown feature>
cv06    <unknown feature>
cv11    <unknown feature>
cv21    <unknown feature>
cv80    <unknown feature>
cv81    <unknown feature>
cv90    <unknown feature>
cv91    <unknown feature>
dlig    Discretionary Ligatures
dnom    Denominators
frac    Fractions
hlig    Historical Ligatures
kern    Kerning
liga    Standard Ligatures
lnum    Lining Figures
mark    Mark Positioning
mkmk    Mark to Mark Positioning
numr    Numerators
onum    Oldstyle Figures
ordn    Ordinals
pnum    Proportional Figures
sinf    Scientific Inferiors
size    Optical Size
smcp    Small Capitals
ss01    Stylistic Set 1
ss02    Stylistic Set 2
ss05    Stylistic Set 5
ss06    Stylistic Set 6
ss20    Stylistic Set 20
subs    Subscript
sups    Superscript
tnum    Tabular Figures


This font has numeral-related features, namely dnom, frac, lnum, numr, onum, ordn, etc.

The fontspec manual will give you the keys to use them, or you can use them directly using the RawFeatures key.

-
I appreciate, but still don't understand how I can use this in order to answer my question. I do know I have text figures, only they are in a different file from that I'm using for my UprightFont face (the *-Regular file). What I'd need is some way to tell Xe(La)TeX to take the numeral glyphs from the *-RegularSC file instead of the *-Regular file. I have tried with RawFeatures=+onum, but it doesn't work. –  Marcos Aug 8 '12 at 8:55

While your fonts do seem strange, it is possible to get XeTeX to automatically select certain glyphs from another font. You can do something like

\documentclass{article}

\usepackage{fontspec}

\setmainfont{Verdana}
\newfontfamily{\numfont}{Times New Roman}

\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\NumSubst

\XeTeXcharclass\1=\NumSubst
\XeTeXcharclass\2=\NumSubst
\XeTeXcharclass\3=\NumSubst
\XeTeXcharclass\4=\NumSubst
\XeTeXcharclass\5=\NumSubst
\XeTeXcharclass\6=\NumSubst
\XeTeXcharclass\7=\NumSubst
\XeTeXcharclass\8=\NumSubst
\XeTeXcharclass\9=\NumSubst
\XeTeXcharclass\0=\NumSubst

\XeTeXinterchartoks 0 \NumSubst = {\begingroup\numfont}
\XeTeXinterchartoks 255 \NumSubst = {\begingroup\numfont}
\XeTeXinterchartoks \NumSubst 0 = {\endgroup}
\XeTeXinterchartoks \NumSubst 255 = {\endgroup}

\begin{document}

abc123

\end{document}

-