# Fake small caps with XeTeX/fontspec?

Using XeTeX and fontspec, I use the Liberation font family in of my documents. Unfortunately those fonts (esp. Liberation Serif) do not natively support small caps.

Is there a way to enable fake small caps in fontspec?

-

Here is a simple solution

\documentclass{article}
\usepackage{fontspec}
\makeatletter
\newlength\fake@f
\newlength\fake@c
\def\fakesc#1{%
\begingroup%
\xdef\fake@name{\csname\curr@fontshape/\f@size\endcsname}%
\fontsize{\fontdimen8\fake@name}{\baselineskip}\selectfont%
\uppercase{#1}%
\endgroup%
}
\makeatother

\begin{document}
\Huge

\fontspec{Minion Pro}
This is real \textsc{small caps} \par
This is fake \fakesc{small caps} \par
\medskip
\fontspec{Didot Lt Std}
This is real \textsc{small caps} \par
This is fake \fakesc{small caps} \par
\end{document}


The effect is here,

Clearly, this will not universally work. The \fakesc will resize the font to Cap size without changing the baselineskip. However, this will depend on the design of the font. With Minion Pro, set in \Huge and thus Minion Pro Disp is in use, setting the fake small caps will use Minion Pro Subh, and thus looks not too bad, since Subh is slightly heavier than Disp. But set in a non-optical size font, say Didot, the contrast of weights is even more observable. In addition, due to different x-height, the fake small caps will looks a little too large. So you would need to adjust the \fontsize accordingly.

-
Consider also this answer, if one uses fontspec and one's font, like Junicode, has native small-caps in normal shape, but lacks them in bold - then a remapping to fontspec's 'FakeBold' can be performed using \DeclareFontShape. Cheers! –  sdaau May 16 '12 at 15:53

The best – and IMHO only acceptable – way to get small caps is to use a font containing them every fake looks bad, since the stroke widths of faked small caps won’t match the real uppercase letter.

Take a look at these images showing Linux Libertine, and make your own decision …

real small caps

faked small caps

-
Correct answer, not to my question though. –  Michael May 13 '12 at 17:59
@Michael: Certainly it’s no answer showing how to get faked small caps but an advice showing why not to want small caps and for that worth to be mentioned here in my opinion ;-) –  Tobi May 13 '12 at 22:27

Yeah if your font does not provide native small caps you can try the following code to make fake caps. Works fine on my side...

\documentclass[]{article}
%\usepackage{fontspec}

\begin{document}

\makeatletter

\def\mycommand{\bgroup\obeyspaces\mycommandaux}
\def\mycommandaux#1{\mycommandauxii #1\relax\relax\egroup}
\def\mycommandauxii#1{%
\ifx\relax#1\else \ifcat#1\@sptoken{} \expandafter\expandafter\expandafter\mycommandauxii\else
\ifnum#1=\uccode#1 {\normalsize #1}\else {\footnotesize \uppercase{#1}}\fi \expandafter\expandafter\expandafter\mycommandauxii\expandafter\fi\fi}

\mycommand{All inside this are fake caps}

\end{document}


Hope it helps ++

-