23

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

Phil
  • 429
  • 1
  • 6
  • 12
  • 1
    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 07: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 07: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 07:50
  • nd btw: What does that have to do with moderncv? – Johannes_B Jul 30 '14 at 07: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 –  Jul 30 '14 at 08:10
  • @Herbert: I am using Texmaker. Checking the settings, I found pdflatex -synctex=1 -interaction=nonstopmode %.tex for pdflatex. I guess that's what you have referred to in your comment. Do you know what would be the right command to be able to use xelatex or lualatex without problems? – Phil Jul 30 '14 at 10:31
  • in TeXmaker simply use xelatex from the compiler list or instead of Quick Build in this screenshot http://www.xm1math.net/texmaker/texmakertop_big.png –  Jul 30 '14 at 10:38
  • @Herbert: that's exactly what I am doing, however, I get the error mentioned above. Maybe you could give me any other advice? – Phil Jul 30 '14 at 10:48
  • Send me your example: hvoss@tug.org I cannot believe that you run it with xelatex –  Jul 30 '14 at 13:48

2 Answers2

14

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

  • 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
  • 1
    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. –  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? –  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
  • Ans was it ok or not??? –  Jul 30 '14 at 20:33
  • Well, it looks as follows, don't know if this output is what I should receive:

    _

    /usr/local/texlive/current/texmf-dist/fonts/opentype /usr/local/texlive/current/texmf- dist/fonts/truetype /usr/local/texlive/current/texmf-dist/fonts/type1

    /usr/local/texlive/texmf-local/fonts/opentype /usr/local/texlive/texmf- local/fonts/truetype _

    That's a part of the output.

    – Phil Jul 30 '14 at 22:29
  • Oh, that is completely wrong. Read carefully what I wrote. That should be saved in a file named fonts.conf. –  Jul 31 '14 at 06:04
  • @Herbert I include this command in fontawesome.sty \expandafter\def\csname faicon@icon-skype\endcsname {\symbol{"F17E}} \def\faSkype {{\FA\csname faicon@icon-skype\endcsname}}. But \faSkype is not working properly just showing the empty box. – Micky K Aug 07 '14 at 15:00
3

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.

Jonathan H
  • 1,000
  • 1
    Thanks for putting links to other answers, saved me a bunch of time. This is useful for macOS users. – seeker Jan 06 '18 at 03:45
  • For more workarounds, I posted an alternative solution for macOS users at the bottom of: https://tex.stackexchange.com/questions/132888/fontawesome-font-not-found/586014#586014 – PatrickT Mar 05 '21 at 22:54