celineu
celineu

Reputation: 586

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

Upvotes: 6

Views: 19904

Answers (4)

SnowyField
SnowyField

Reputation: 147

Had same problem! After hours struggling, I solved by using fontawesome5 instead, there are small changes with icon names following by this link: https://mirrors.ibiblio.org/CTAN/fonts/fontawesome5/doc/fontawesome5.pdf

Upvotes: 0

Joshpy
Joshpy

Reputation: 600

Once download the font file from FontAwesome and install to be system font, open the font application and confirm the FontAwesome name.

Due to FontAwesome version is 5.7.2 at this time, this version has three font type in system font.

Their names are

Font Awesome 5 Free Regular

Font Awesome 5 Free Solid

Font Awesome 5 Brands Regular

So define command for FontAwesome:

\newfontfamily{\FAFR}{Font Awesome 5 Free Regular}
\newfontfamily{\FAFS}{Font Awesome 5 Free Solid}
\newfontfamily{\FAB}{Font Awesome 5 Brands Regular}

Simply redefine:

\def\faEmail{{\FAFR \symbol{"F0E0}}} % Email
\def\faPhone{\FAFS \symbol{"F095}} % Phone
\def\faLinkedin{\FAB \symbol{"F08C}} % Linkedin
\def\faGithub{\FAB \symbol{"F09B}} % Github
\def\faStackOverflow{\FAB \symbol{"F16C}} % StackOverflow

Upvotes: 5

udothemath
udothemath

Reputation: 137

I found this video (https://www.youtube.com/watch?v=OlpVKUpraao) particularly useful. Please do the following.

  1. Follow the instruction given by the video (putting FontAwesome.otf into OSX Font Book application)
  2. Put \usepackage{fontawesome} into the XeLaTeX preamble
  3. Define command for FontAwesome: \newfontfamily{\FA}{FontAwesome} (Note: FontAwesome instead of FontAwesome Regular works for me)
  4. Redefine required characters (optional): \def\mytweet{{\FA\symbol{"F099}}} . You can find more symbols here (http://fontawesome.io/cheatsheet/). (Note: All letters are in capital, f099 won't work)
  5. Use: \href{http://twitter.com/}{\mytweet} as a clickable tweet icon

Upvotes: 1

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

Upvotes: 4

Related Questions