1

I would like to change the default font for fancyvrb in the following MWE.

    % arara: xelatex: { shell: true }
    \documentclass{article}
    \usepackage[svgnames]{xcolor}
    \usepackage{fontspec}
    \usepackage{fancyvrb}
    
    \newfontface{\cBld}{SourceSansPro-Bold.ttf}
    \newfontface{\cEm}{SourceSansPro-LightItalic.ttf}
    \newfontface{\cNrm}{SourceSansPro-Regular.ttf}
    
    \def\It#1{{\cEm #1}}
    \def\Bf#1{{\cBld #1}}
    \def\Br#1{{\color{IndianRed}{\cNrm #1}}}
    \def\Bl#1{{\color{CornflowerBlue}{\cNrm #1}}}
    \def\Gr#1{{\color{LimeGreen}{\cNrm #1}}}
    
    \begin{document}
    \begin{Verbatim}[commandchars=\\\{\}, numbers=left]
    \It{;;}
    \It{;; goff.ufm}
    \It{;; 13:00:35 11:08:2021 (MST)}
    \It{;;}
    MyGoFF \{
    \Bf{init:}
      z = \Br{@Z}
      \Bf{complex} zf = \Br{@ZF}
    
    \Bf{loop}:
      \Bf{if} \Br{@fof} > 0
        zf = Utils.\Bl{fofz}(\Br{@inverse}, \Br{@fof}, Utils.\Bl{zFunction}(\Br{@inverse}, \Br{@fofz},  z, \Gr{\#pixel}))
        z  = Utils.\Bl{fofz}(\Br{@inverse}, \Br{@fof}, Utils.\Bl{gFunction}(\Br{@inverse}, \Br{@gofz}, zf, \Gr{\#pixel}))
      \Bf{else}
        zf = Utils.\Bl{zFunction}(\Br{@inverse}, \Br{@fofz},  z, \Gr{\#pixel})
        z  = Utils.\Bl{gFunction}(\Br{@inverse}, \Br{@gofz}, zf, \Gr{\#pixel})
      \Bf{endif}
      \Bf{if} \Br{@const} > \Bl{0}
        \Bf{if} \Br{@op} == \Bl{0}
          z = z * Utils.\Bl{GetConstant}(\Br{@const});
        \Bf{elseif} \Br{@op} == \Bl{1}
          z = Utils.\Bl{GetConstant}(\Br{@const}) / z;
        \Bf{elseif} \Br{@op} == \Bl{2}
          z = z + Utils.\Bl{GetConstant}(\Br{@const});
        \Bf{elseif} \Br{@op} == \Bl{3}
          z = Utils.\Bl{GetConstant}(\Br{@const}) - z;
        \Bf{elseif} \Br{@op} == \Bl{4}
          z = z / Utils.\Bl{GetConstant}(\Br{@const});
        \Bf{elseif} \Br{@op} == \Bl{5}
          z = z - Utils.\Bl{GetConstant}(\Br{@const});
        \Bf{elseif} \Br{@op} == \Bl{6}
          z = z\^{}\Bl{2} + Utils.\Bl{GetConstant}(\Br{@const});
        \Bf{elseif} \Br{@op} == \Bl{7}
          z = z\^{}\Bl{2} - Utils.\Bl{GetConstant}(\Br{@const});
        \Bf{endif}
      \Bf{endif}
    \end{Verbatim}
    \end{document}

I have tried every work-around I could come up with but cannot get fancyvrb to use any thing but it's hard coded default or alternatives it provided for. The manual says that:

4.1.5 
Fonts fontfamily (family name) : font family to use. tt, courier and
helvetica are predefined (Default: tt).

I have tried helvetica, but then I run into the problem of differing character sizes of one font versus another. I want to use SourceSansPro-Regular.ttf but have not determined how. In my attempts, I have tried all variants of the fonts name:

    Family:              Source Sans Pro
    Subfamily:           Regular
    Full name:           Source Sans Pro Regular
    PostScript name:     SourceSansPro-Regular

None of these make the slightest difference. I believe the clue lies in the word 'predefined.' I did not see any API to accomplish this—the methods given did not effect any change.

If I could change the font, everything else works the way I want it. This is an effort to prototype a semi-'listings' environment. The language (Ultra Fractal's formula language) in question fits no parser otherwise available.

I'm using MikTeX 2.9 under Windows 11 (bleeding edge), the font family is available at https://fonts.google.com/specimen/Source+Sans+Pro

0
3

This is described in the fontspec documentation in 4.2 Specifically choosing the NFSS family:

\documentclass{article}
\usepackage{fontspec}
\usepackage{fancyvrb}
   
\newfontfamily\verbatimfont{SourceSansPro-Regular.ttf}[NFSSFamily=myverbatimfont]
    

\begin{document}
\begin{Verbatim}[fontfamily=myverbatimfont]
aaaa
\end{Verbatim}
\end{document}
    
1
  • 1
    Looked at that and totally misconstrued the 'NFSSFamily' as not being applicable...silly me! Thanks again @Ulrike!
    – hsmyers
    Aug 15 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.