# Small caps in fontspec on XeLaTeX

I'm trying to typeset my document with Times with XeLaTeX. Because Times does not include small caps, I want to use TeX Gyre Termes only for small caps. I tried this method, but it didn't work. A warning is issued and the output is not small caps.

The question:

• What is wrong?
• How can I do this?

Here's a MWE:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[
SmallCapsFont={TeX Gyre Termes},
SmallCapsFeatures={Letters=SmallCaps},
]{Times}
\begin{document}
Hello!
\textsc{Hello!}
\end{document}


and the warning:

*************************************************
* fontspec warning: "aat-feature-not-exist-in-font"
*
* AAT feature 'Letters=SmallCaps' (3,3) not available in font 'TeX Gyre
* Termes'.
*************************************************


What I've tried:

• I tried typesetting with LuaLaTeX and the result was fine with no warnings.
• I replaced Times with Times New Roman and there was no problem.
• I added Renderer=ICU and the warning changed to icu-feature-not-exist-in-font. It seems that fontspec can use .dfont with ICU?
• I replaced Times with another .dfont font Helvetica Neue and the problem disappeared. Thus not all .dfont font cause the problem....

I'm using MacTeX 2013 on OS X Mountain Lion.

Update

Following a suggestion from @KhaledHosny, I tried adding \the\XeTeXfonttype\font before and after \textsc{, and both returned 1 (AAT font). With Render=ICU they returned 2 (OpenType font), but I got no small caps. It seems that XeTeX can treat Times as OpenType, but even then SmallCapsFeatures doesn't work.

• Have you checked if there's a font provided by the OS that's called Times? XeLaTeX will work with system-installed fonts, while LuaLaTeX searches for fonts more broadly. – Mico Mar 17 '14 at 9:33
• @Mico Yes. Both Times and TeX Gyre Termes are listed in Font Book.app. – a user Mar 17 '14 at 9:37
• I have no problem with my version of the Times: Times New Roman PS Std. However, my Times version has also Small Caps, the reason why I do not need the TeX Gyre Termes. But it also works with the small caps from Termes. – user2478 Mar 17 '14 at 9:43
• The “Times” font is in .dfont format and apparently fontspec is not able to use it other than with the AAT renderer, which is not available for TeX Gyre Termes; you should also have a Times New Roman.ttf in /Library/Fonts and on my system the combination works. – egreg Mar 17 '14 at 9:53
• While the font is active, \the\XeTeXfonttype\font should print the type of the font engine XeTeX choses for this font (0 for TFM fonts, 1 for AAT, 2 for OpenType and 3 for Graphite). – Khaled Hosny Mar 17 '14 at 12:39

I found that this can be achieved with NFSS.

First, Times and TeX Gyre Termes are loaded separately. Then the definition of small caps of Times in NFSS is overwritten so that it redirects to small caps of TeX Gyre Termes.

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Times}

\newfontfamily\tgtermes{TeX Gyre Termes}
\makeatletter
\begingroup
\tgtermes
\DeclareFontShape{\f@encoding}{\rmdefault}{m}{sc}{%
<-> ssub * \f@family/m/sc}{}
\DeclareFontShape{\f@encoding}{\rmdefault}{bx}{sc}{%
<-> ssub * \f@family/bx/sc}{}
\endgroup
\makeatother

\begin{document}

Hello!
\textsc{Hello!}

\end{document}

• That's a clever workaround. I've been aware for some time that the Renderer option was somewhat restrictive in that it applies to all individual fonts in a "family"… but this is the first time that someone's bumped into a limitation :) I'll keep it in mind next time I'm updating fontspec. – Will Robertson Nov 9 '15 at 22:48

Maybe the easiest way is as follows:

In the example, Crimson Text does not have smallcaps, but Crimson does. (The scale used here has only to do with better-looking output in this case.)

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Crimson Text}

\newfontinstance\scshape[Letters=SmallCaps,Scale=1.15]{Crimson}

\begin{document}
Text \textsc{Text}
\end{document}


UPDATE as noted here, \newfontinstance no longer works, replaced with \newfontfamily.