# How to use fontawesome-package in moderncv?

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}

\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

• Does the use of LuaTex or XeTeX cause any trouble with the fontawesome package? It seems that it load the fontspec package and you need to compile with one of the two – Romain Picot Jul 30 '14 at 7:41
• It is clearly stated in the fontawesome documentation that you need to run XeLateX or LuaLaTeX. The error message you receive says that you are using pdftex. – Johannes_B Jul 30 '14 at 7:49
• Thanks for your reply @Romain Picot. Neither with the fontawesome nor the fontspec package it works. Further, the error message remains the same in both cases. – Phil Jul 30 '14 at 7:50
• nd btw: What does that have to do with moderncv? – Johannes_B Jul 30 '14 at 7:52
• It looks like that you have a hidden first line in your document, something like %! pdflatex, which tells the editor that it should always run pdflatex. Look for sucha line and delete it. With current TeXLive 2014 your example works very well with xelatex or lualatex – user2478 Jul 30 '14 at 8:10

My example:

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

\end{document}


run with xelatex or lualatex

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

• Thanks for this detailed answer. However, I do not get what I should do. Are these commands for LaTeX? Probably I am simply too stupid... Is there no easy way to use the fontawesome package? – Phil Jul 30 '14 at 13:00
• copy the abobe example into a new document of TeXmaker. Then run it with xelatex. If there is an error then have a look into the settings of your commands. – user2478 Jul 30 '14 at 13:50
• Ok, thanks for the clarification. I do not get any error. Maybe it is important to know that I used as documentclass article. What should I do next? – Phil Jul 30 '14 at 14:37
• If you had no error then you had a pdf output, right? – user2478 Jul 30 '14 at 14:52
• Sorry for the late response, but yes, i had a pdf output. – Phil Jul 30 '14 at 20:28

Just to share my own experience on OSX El Capitan, Herbert's answer almost solved my problem. See also these relevant posts:

• These two posts are very similar to Herbert's: one, two
• This archive is relevant to this problem

Here is what ran without error in my case:

• Copy Herbert's XML file to ~/.fonts.conf (and not ~/fontconfig/fonts.conf as suggested);
• Run fc-cache -fv (takes a while);
• Compile Herbert's example document using lualatex (takes a while);
• If you are using latexmk, you can set the flag -pdflatex=lualatex to use LuaLaTeX instead.

If you need the more recent upgrades of the packages though (with newer symbols), this is not sufficient. In my case, the version of TexLive installed was 2015, and I had to install the latest version (2017) from scratch instead. You can find the installer here.

• Thanks for putting links to other answers, saved me a bunch of time. This is useful for macOS users. – SPV Jan 6 '18 at 3:45