[Tex/LaTex] How to use fontawesome-package in moderncv

fontawesomemoderncv

since I am working on my CV using moderncv, I was wondering if it is possible to change the icons used in the header. These icons are from the package marvosym. As indicated by this question moderncv – non marvosym symbols, you can use the fontawesome-package.

\documentclass{article}
\usepackage{fontawesome}

\begin{document}
\faTwitter

\faLinkedin

\faLinkedinSign
\end{document}

Seems to be easy, but unfortunately I receive an error message even if I compile with xelatex or lualatex. The error indicates the following:

! Fatal fontspec error: "cannot-use-pdftex"
!
! The fontspec package requires either XeTeX or LuaTeX to function.
!
! You must change your typesetting engine to, e.g., "xelatex" or "lualatex"

Both xelatex and lualatex are functioning well with other codes. Hence, I do not know what's the problem. However, I would really like to use the icons from the fontawesome-package.

Does anybody has an idea?

Thank you very much in advance,

Phil

Best Answer

My example:

\documentclass{moderncv}
\usepackage{fontawesome}
\firstname{H}\lastname{foo}    
\begin{document}
\faTwitter

\faLinkedin

\faLinkedinSign
\end{document}

run with xelatex or lualatex

enter image description here

The otf version of FontAwesome is saved in the TeXLive path which is by default not searched by xetex. luatex uses its own font handling and will find the file. One can test it:

voss@shania:~> fc-list | grep fontawesome
/usr/local/texlive/current/texmf-dist/fonts/opentype/public/fontawesome/FontAwesome.otf: FontAwesome:style=Regular

if there is no output then xelatex will not find the font. In a file ~/fontconfig/fonts.conf I have

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <dir>/usr/local/texlive/current/texmf-dist/fonts/opentype</dir>
 <dir>/usr/local/texlive/current/texmf-dist/fonts/truetype</dir>
 <dir>/usr/local/texlive/current/texmf-dist/fonts/type1</dir>
 <dir>/usr/local/texlive/texmf-local/fonts/opentype</dir>
 <dir>/usr/local/texlive/texmf-local/fonts/truetype</dir>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>none</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintmedium</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>
 <dir>~/.fonts</dir>
</fontconfig>

which tells fontconfig also to search for fonts in /usr/local/texlive/current/... . current is always a link which points to the current TL version. After creating that file run fc-cache -fv.

Test your file with lualatex, it should generate the font list by default if it doesn't find awesome. Or run luaotfload-tool --update --force before testinmg it with lualatex

Related Question