Search code examples
fontslatexfont-awesome

XeLaTex + FontAwesome


I am trying to use FontAwesome in XeLaTex on OS X. So I followed the steps described on this github:

  1. Save this into your project folder as fontawesome.sty
  2. Put \usepackage{fontawesome} into the preamble
  3. Define command for FontAwesome: \newfontfamily{\FA}{FontAwesome Regular}
  4. Redefine required characters (optional): \def\twitter{{\FA \faTwitter}}
  5. Use: \href{http://twitter.com/swaycz}{\twitter\ swaycz}

So that the beginning of my .tex file look like this:

\documentclass{.......}
\usepackage{fontspec}
\usepackage{fontawesome}
\newfontfamily{\FA}{FontAwesome Regular}
\begin{document}

But I keep getting this error:

kpathsea:make_tex: Invalid fontname `FontAwesome Regular', contains ' '
kpathsea:make_tex: Invalid fontname `FontAwesome Regular', contains ' '

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
! 
! The font "FontAwesome Regular" cannot be found.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

It seems like it is not finding the font. After some research, I tried loading the font with:

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

instead of \newfontfamily{\FA}{FontAwesome Regular} but it was not working either.

I am still new with LaTex and I do appreciate your time, thank you


Solution

  • Fontspec taps into your system fonts by default, so: FontAwesome needs to be installed as a normal system font like every other. If you don't see it in Fontbook or the like, you didn't install it properly.

    (lines 7 and 8 of the gist you quote mention this, but I'm reiterating it just in case)

    If instead you want to run it "from file" rather than installing it as system font, don't use \newfontfamily{\FA}{FontAwesome Regular} but use the "from path" way to load a font file, as explained over on the tex.stackexchange site, in https://tex.stackexchange.com/questions/12565/load-fonts-that-are-in-a-fonts-directory