Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 769
celineu Avatar asked Jun 06 '15 00:06

celineu


People also ask

What files do I need for Font Awesome?

Add Font Awesome Files to Your Project Be sure to include the core styling file - /css/fontawesome.css - as well as the CSS files for any individual styles you want to use, and you can remove any .css and web font files you don't plan on using.


1 Answers

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
like image 194
Joshpy Avatar answered Oct 26 '22 05:10

Joshpy