[XeTeX] How to fake SmallCaps in Fontspec?

Sven Siegmund sven.siegmund at gmail.com
Thu Jul 17 19:35:46 CEST 2008


Hello,

I use DejaVu fonts but they don't have small caps.
I really need such thing so I want at least fake them. I'd like to use
the \cap command for that, like
\cap{text in small caps}


Looking at the examples in fontspec documentation, of p. 6 I found this:

\fontspec[SmallCapsFont={font for smallcaps}]{font generally used}
But somehow it does not do what I want. Where shall I put the Scaling factor in?

What I tried is this:

\fontspec[Scale=0.8]{DejaVu Sans}
The command above defines basically a new font from now onwards. Since
I need it just for one or two words, I tried this:


\documentclass{article}
\usepackage{xltxtra} % XeTeX extras
\setmainfont[Mapping=tex-text]{DejaVu Sans} % use this font and handle
`` "" -- ---
\setmonofont[Mapping=tex-text,Scale=MatchLowercase]{DejaVu Sans Mono}
% use this mono font.
\setsansfont[Mapping=tex-text,Scale=MatchLowercase]{DejaVu Sans} % use
this sans font.
\renewcommand{\cap}[1]{{\fontspec[Scale=0.8]{DejaVu Sans}#1}} %fake smallcaps

\begin{document}
Normal font but \cap{THIS PART} is faked small caps.
\end{document}

Is that ok? How can I make the smallcaps command independent of the
current font name? for example If somewhere the main font changes to
Serif, I'd like to have scaled DejaVu Serif for smallcaps.

S.


More information about the XeTeX mailing list