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.

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?

share|improve this question

4 Answers 4

You can also use FontForge to add automatically generated real small caps to the font. It's still not the same as real real small caps but it's way better than faked small caps: http://fontforge.sourceforge.net/Styles.html#Smallcaps

share|improve this answer

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, enter image description 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.

share|improve this answer
    
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
    
My understanding is that small-caps is supposed to leave the real capital letters normal, and only the convert the lower case letters to be small capital letters. This script appears to eliminate the upper case-ness of characters, making all characters, upper and lower, appear the same. Try a test case with both upper and lower characters, please. –  AgilePro yesterday

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 ++

share|improve this answer
    
I tried this and it almost worked. I seem to lose all the spaces in the string: all the words are smashed together. Any solution to that? –  AgilePro yesterday

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 …

right
real small caps

wrong
faked small caps

share|improve this answer
4  
Correct answer, not to my question though. –  Michael May 13 '12 at 17:59
1  
@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

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.