0

I would like to use this solution by @egreg to type in fake small caps.

It works perfectly, except it seems that I cannot change the font size using \fontsize{}{}\selectfont.

On this example, both lines \frutB \fontsize{8}{12}\selectfont \underline{\fakesc{Chapitre 2}} and \frutB \fontsize{5}{12}\selectfont \underline{\fakesc{Chapitre 2}} give the same output.

Does anyone have an idea of how to change the font size?

Thank you all!

\documentclass[12pt,twoside]{book}

\usepackage[french]{babel}

\usepackage{fontspec}

\setmainfont{FrutigerLTStd-Roman.otf}[BoldFont=FrutigerLTStd-Bold.otf]


\ExplSyntaxOn
\NewDocumentCommand{\fakesc}{ o m }
 {
  \guido_fakesc:n { #2 }
  \IfNoValueTF{#1}
   {
    \tl_use:N \l__guido_temp_tl
   }
   {
    \cs_set_eq:NN #1 \l__guido_temp_tl
   }
 }
\cs_new_protected:Npn \guido_fakesc:n #1
 {
  \tl_set:Nn \l__guido_text_tl { #1 }
  \tl_replace_all:Nnn \l__guido_text_tl { ~ } { \q_space }
  \tl_set:Nn \l__guido_temp_tl { \group_begin: \footnotesize }
  \tl_map_inline:Nn \l__guido_text_tl
   {
    \token_if_eq_meaning:NNTF ##1 \q_space
     {
      \tl_put_right:Nn \l__guido_temp_tl { ~ }
     }
     {
      \int_compare:nTF { \char_value_uccode:n { `##1 } = `##1 }
       {
        \tl_put_right:Nn \l__guido_temp_tl { {\normalsize ##1} }
       }
       {
        \tl_put_right:Nn \l__guido_temp_tl { \tl_upper_case:n { ##1 } }
       }
     }
   }
  \tl_put_right:Nn \l__guido_temp_tl { \group_end: }
 }
\quark_new:N \q_space
\tl_new:N \l__guido_text_tl
\tl_new:N \l__guido_temp_tl
\ExplSyntaxOff

\usepackage{contour}


\begin{document}


\fontsize{8}{12}\selectfont \underline{\fakesc{Chapitre 2}}

\fontsize{5}{12}\selectfont \underline{\fakesc{Chapitre 2}}


\end{document}
Guliup
  • 96
  • Why do you still use all this families? Beside this: Use a free font for such examples. Not every one has Frutiger and you will get more help if you don't make it too difficult to test your code. And remove unneeded packages - your problem doesn't relate to tikz or supertabular. – Ulrike Fischer May 19 '20 at 17:48
  • @UlrikeFischer yes yes sorry I was about to edit my code with your suggestion :). You are right it is much cleaner. Please excuse my laziness! – Guliup May 19 '20 at 17:51
  • @UlrikeFischer edited ! – Guliup May 19 '20 at 18:03
  • See also: https://tex.stackexchange.com/questions/55664/fake-small-caps-with-xetex-fontspec?rq=1 – Davislor May 19 '20 at 23:25

0 Answers0