42

I'm using the latest version of MacTeX 2013 on OS X 10.8.4. All of my Tex Live packages are fully up-to-date. Tex Live also lists the fontawesome package as installed.

I'm trying to use the FontAwesome font with XeLatex or LuaLatex and getting font-not-found errors. The exact message is:

kpathsea: Running mktexmf FontAwesome
! I can't find file `FontAwesome'.

There's a longer traceback which I am omitting for brevity. Let me know if it's needed to resolve this problem.

I have already tried running the following commands, to no avail:

sudo -H mktexlsr
sudo -H updmap-sys

Other than the above two commands, this is a 100% new out-of-the-box installation, with no modifications whatsoever.

Here's a minimal broken example:

\documentclass{article}
\usepackage{fontawesome}

\begin{document}
\faTwitter
\end{document}

How can I add this missing font?

  • 1
    FontAwesome can be found at CTAN at this location. I am not sure how you can add this to your OS X 10.8.4, I do not use this OS or MacText. But did you take a look at this one? – Masroor Sep 12 '13 at 4:02
  • FontAwesome provides an OTF font, which apparently is not being copied to the correct font directory. This post suggests how you might proceed – Llaves Sep 12 '13 at 5:28
  • @Llaves - It's probably not so much an issue of the font file not being copied to the correct directory but of the font not having been "activated" correctly. Just copying a font file to the user's ~/Library/Fonts directory doesn't activate it, at least not in a way suitable for use under MacOSX. Under MacOSX, the easiest way I know to "activate" a font is to load it in the FontBook application and click on the "Install Font" button. Doing so also copies the font file to ~/Library/Fonts... – Mico Sep 12 '13 at 6:45
  • @Mico Luaotfload doesn’t care for a font’s “activation state” (whatever that is). As long as it is in a system path the font will be indexed. I suggest that OP remove the package and copy the otf files into the system font path manually. Then run luaotfload-tool --update and retry. – Philipp Gesang Sep 12 '13 at 8:36
  • @phg -- I may not have expressed myself sufficiently clearly. As I noted in the "full" answer, LuaLaTeX was able to compile the MWE even before the otf version of the font was downloaded and "officially activated". It was XeLaTeX that couldn't compile the MWE before the font was properly activated. – Mico Sep 12 '13 at 11:38
22

On my MacBook (running MacTeX 2013 under MacOSX 10.7.5), your example compiles correctly under LuaLaTeX (but not XeLaTeX) if I add the instruction \usepackage{fontspec}:

enter image description here

% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{fontspec}
\usepackage{fontawesome}
\begin{document}
\faTwitter
\end{document}

Addendum: After I downloaded the OpenType version of this font -- BTW, the version at http://fortawesome.github.io/Font-Awesome/ seems to be slightly newer than the one on the CTAN -- and "activated" it by opening it in the FontBook application and clicking on the "Install" button, the MWE above also compiles correctly under XeLaTeX. This is not exactly surprising, I suppose, as Xe(La)TeX depends heavily on the underlying operating system for activities such as loading fonts.

  • 5
    \usepackage{fontspec} did the trick. I'm actually using the moderncv package, which recently added support for FontAwesome icons. I'll contact the author and suggest he add the fontspec package to his template. – knite Sep 12 '13 at 18:09
  • "Opening in the FontBook application". For recent versions of Mac OS: "File" > "Validate File ..." > Select the OTF file and after validating check box to install font. Get the OTF file from GitHub here: github.com/FortAwesome/Font-Awesome/tree/master/fonts – Unapiedra Feb 2 '18 at 11:03
  • @Mico your answer gives hints on how to activate a font using FontBook. This part of the answer is out of date as FontBook changed the wording for the menus in their application. – Unapiedra Feb 2 '18 at 11:18
  • @Unapiedra - Thanks. I don't think it's right to say that the method I described, back in Sept. 2013, is "out of date". For sure, it is still possible to drag-and-drop font files from the Finder onto the FontBook icon and then to click on the "Install" button that pops up in a dialogue box. By the way, your alternative method deserves a separate answer, not just a comment below mine. Please consider posting a new answer; that way, it'll be seen by many more people. – Mico Feb 2 '18 at 11:30
  • 1
    @ColonD - Ok. Am away from my Mac laptop all day -- will update this answer tonight. – Mico Mar 8 at 9:40
16

If anyone wants to get this working with xelatex without installing the font into your system, see section 4.2 By file name of the fontspec.pdf manual:

[Loading the font by file name] is also necessary in XeTeX when loading OpenType fonts that are present within your TEX distribution, such as /usr/local/texlive/2013/texmf-dist/fonts/opentype/public. Fonts in such locations are visible to XeTeX but cannot be loaded by font name, only file name; LuaTEX does not have this restriction.

Since fontawesome.sty simply references the font by name:

% definition of \FA as a shortcut to load the Font Awesome font
\newfontfamily{\FA}{FontAwesome}

We have to set the default Path to locate the font, before loading fontawesome:

\documentclass{article}
\usepackage{fontspec}

\defaultfontfeatures{
    Path = /usr/local/texlive/2013/texmf-dist/fonts/opentype/public/fontawesome/ }
\usepackage{fontawesome}

\begin{document}
\faTwitter
\end{document}

You may have to change Path depending on where fontawesome is installed. Assuming you're using TeX Live, you can find the relative path to the font file by running:

tlmgr info --list fontawesome

Output:

package:     fontawesome
category:    Package
shortdesc:   Font containing web-related icons.
longdesc:    The package offers access to the large number of web-related icons provided by the included font. The package requires the package, fontspec, running under XeTeX or LuaTeX.
installed:   Yes
revision:    31020
sizes:       doc: 173k, run: 101k
relocatable: Yes
cat-version: 3.1.1
cat-date:    2014-04-26 20:05:48 +0200
cat-license: other-free
collection:  collection-fontsextra
Included files, by type:
run files:
  texmf-dist/fonts/opentype/public/fontawesome/FontAwesome.otf
  texmf-dist/tex/latex/fontawesome/fontawesome.sty
doc files:
  texmf-dist/doc/latex/fontawesome/README details="Readme"
  texmf-dist/doc/latex/fontawesome/fontawesome.pdf
  texmf-dist/doc/latex/fontawesome/fontawesome.tex
11

Ultimately, you need /path/to/FontAwesome.otf to be produced by \newfontfamily\FA[Path=/path/to/,Extension=.otf]{FontAwesome}.

Note this answer assumes you didn't add the TeX Live fonts to the system environment variables such that they are found when fontspec searches the system fonts. (either because you don't know how or because it isn't practical e.g. multi-client Version Control System situation where you can't guarantee that every client has the same system environment variables).

Assuming you are using XeLaTeX: To minimize maintenance with each sequential TeX Live release (2015,2016, etc.), I chose to add \defaultfontfeatures{Extension = .otf} rather than provide an explicit path.

This is because XeLaTeX automatically loads $(kpsewhich -var-value TEXMFSYSVAR)/fonts/conf/texlive-fontconfig.conf into its path.

texlive-fontconfig.conf from TeX Live 2015

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>/usr/local/texlive/2015/texmf-dist/fonts/opentype</dir>
  <dir>/usr/local/texlive/2015/texmf-dist/fonts/truetype</dir>
  <dir>/usr/local/texlive/2015/texmf-dist/fonts/type1</dir>
</fontconfig>

With each release, this gets updated, so you don't have any maintenance costs ;)

So you only need to add the extension parameter to \newfontfamily{\FA}{FontAwesome} indirectly this way. This is of course provided that the fonts you're using are OTF.

\documentclass{article}
\usepackage{fontspec}

\defaultfontfeatures{Extension = .otf}% adds .otf to end of path when font loaded without ext parameter e.g. \newfontfamily{\FA}{FontAwesome} > \newfontfamily{\FA}{FontAwesome.otf}
\usepackage{fontawesome} % Relevant path loaded (TeX Live 2015 expansion): /usr/local/texlive/2015/texmf-dist/fonts/opentype/FontAwesome causing missing font

\begin{document}
\faTwitter This is a test.
\end{document}

As a fun exercise to prove your understanding, you could create a document like this:

\listfiles
\documentclass{article}
\usepackage{fontspec}

%\defaultfontfeatures{
%  Extension = .otf
%}
%\usepackage{fontawesome}
\newfontfamily\fatest{FontAwesome.otf} % Explicitly provide .otf
%or
%\newfontfamily\fatest[Extension=.otf]{FontAwesome}


\begin{document}
%\faTwitter This is a test
{\fatest\char"F099} This is a test
\end{document}

This works because the following are equivalent:

  • \newfontfamily\fatest{FontAwesome.otf}
  • \newfontfamily\fatest[Extension=.otf]{FontAwesome}
  • \defaultfontfeatures{Extension = .otf}\newfontfamily{\fatest}{FontAwesome}

because they all yield a platform-independent paths.

e.g. Unix-based:

/usr/local/texlive/2015/texmf-dist/fonts/opentype/FontAwesome.otf

and fontspec will try to load a font by adding each prefix listed in this xml file:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
ANYTHING IN HERE GETS PREFIXED to the font file
</fontconfig>

See tex.stackexchange.com/a/313886/13552

  • with your command \newfontfamily\fatest{FontAwesome.otf}, how can I join it with FA[Path=\@fontdir]... where I have an example which originally used \newfontfamily\FA[Path=\@fontdir]{FontAwesome} – lukeg Apr 2 '17 at 12:12
  • 1
    @lukeg I am not sure what you mean by "join it", but I assume you mean "make it compatible with". Without knowing what your \@fontdir contains, I would venture to guess that you just need to add ,Extension = .otf as a parameter to \newfontfamily\FA. Do not forget to add a trailing slash to the path! If your \@fontdir contains a path other than the built-in TeX Live FontAwesome.otf path, then you'd need to put a copy of FontAwesome.otf at that path. Ultimately, you need /path/to/FontAwesome.otf to be produced by \newfontfamily\FA[Path=\@fontdir,Extension=.otf]{FontAwesome}. – Jonathan Komar Apr 3 '17 at 14:48
5

You just need to install (by double clicking) the FontAwesome.otf that comes with MacTeX on the macOs system fonts. (The new fonts downloaded from github didn't work for me.)

My FontAwesome.otf is in:

/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/fontawesome

You can locate your file with:

tlmgr info --list fontawesome
  • 2
    you need to be higher, this is the best method to get the correct version of the font – ColonD Mar 8 at 9:24
  • This is the only answer that helped me to get Developer CV working. Thanks! – user190341 Aug 19 at 19:25
  • This answer did it for me. I used lualatex and ran it twice. First time it compiled the font, then the second time it picked itup. However, I imagine I could add more search paths to the ${TEXMFSYSVAR}/fonts/conf/fonts.conf. – Pred Oct 1 at 1:37
3

On Ubuntu, you can install fontawesome using the following command:

sudo apt-get install texlive-fonts-extra 
2

I guess it might be caused by missing a step of post-installation of TeX Live. From the instruction provided tug.org, it would be like this below.

  1. Make sure you have imported TeX Live binaries to your PATH. If not, you may refer this section.
  2. Check the value of TEXMFSYSVAR.

    $ kpsewhich --var-value TEXMFSYSVAR
    
  3. Copy TEXMFSYSVAR/fonts/conf/texlive-fontconfig.conf to your font config directory (e.g. to /etc/fonts/conf.d/09-texlive.conf). Or if you have not enough privileges to do, you may copy to your HOME direcotory as well, e.g.

    $ cp `kpsewhich --var-value TEXMFSYSVAR`/fonts/conf/texlive-fontconfig.conf \
      ~/.fonts.conf
    
  4. Run fc-cache to refresh fontconfig

    $ fc-cache -fv
    

    If you copy the conf file to a system-wide directory, e.g. /etc/fonts/conf.d as mentioned before, probably you need to run

    $ sudo fc-cache -fsv
    

    or

    # fc-cache -fsv
    
  5. Eventually, check fc-list to make sure you've installed fontawesome

    $ fc-list | grep 'fontawesome'
    
1

The fontawesome package when using XeLaTeX assumes that the file FontAwesome.otf exists in the right place, but recent versions of FontAwesome, will install Font Awesome 5 Free-Regular-400.otf and Font Awesome 5 Free-Solid-900.otf.

I thought about playing with defaultfontFeatures[FontAwesome] after \usepackage{fontspec} and before \usepackage{fontawesome}, but a much simpler approach was to find an version of FontAwesome.oft and simply install that on my Mac.

  • This is a useful answer for anyone who did install the current Font Awesome desktop files. Just to add to it, the last Font Awesome 4 release (4.7.0) provides a FontAwesome.otf. – Sean Leather Apr 1 at 13:25
1

On Ubuntu 19.04:

sudo apt install texlive-fonts-recommended

Then use fontawesome5:

 \documentclass{article}
 \usepackage{fontawesome5}

 \begin{document}
 \faTwitter
 \end{document}

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.