[Tex/LaTex] Use an *.otf font with fontspec

fontsfontspecxetex

I an running Tex Live 2012 and would like to use the font Fira Sans in my documents. Unfortunately it is a relatively new font so not included in any of the packages for this version of Texlive.

However I have downloaded the .otf files and placed them in /home/gthomson/texmf/fonts/opentype/Fira and am trying to call them in xeLatex like this, following the fontspec docs:

\documentclass[12pt,twoside]{article}

\usepackage{fontspec}

\begin{document}

\setmainfont{FiraSans-Regular.otf}[
Path = /home/gthomson/texmf/fonts/opentype/Fira,
BoldFont = FiraSans-Bold.otf,
ItalicFont = FiraSans-Italic.otf,
BoldItalicFont  = FiraSans-BoldItalic.otf]

\section{EXAMPLE}

EXAMPLE EXAMPLE EXAMPLE EXAMPLE EXAMPLE\\
\textbf{EXAMPLE} \textbf{EXAMPLE} \textbf{EXAMPLE} \textbf{EXAMPLE} \textbf{EXAMPLE}\\
\textit{EXAMPLE} \textit{EXAMPLE} \textit{EXAMPLE} \textit{EXAMPLE} \textit{EXAMPLE}\\


\end{document}

This only works partially as while the font is loaded, only the regular version is, not the bold or italicised versions. This is despite the files being located in the same location. Furthermore the call for these fonts is printed out So what I get looks like this:

[ Path = /home/gthomson/texmf/fonts/opentype/Fira, BoldFont = FiraSans-
Bold.otf, ItalicFont = FiraSans-Italic.otf, BoldItalicFont = FiraSans-BoldItalic.otf]

1 EXAMPLE

EXAMPLE EXAMPLE EXAMPLE EXAMPLE EXAMPLE

EXAMPLE EXAMPLE EXAMPLE EXAMPLE EXAMPLE

EXAMPLE EXAMPLE EXAMPLE EXAMPLE EXAMPLE

How can I get all versions of the font to load?

Best Answer

Since you have TeX Live 2012, you probably have an old version of fontspec which does not support the new syntax for \setmainfont.

So, either

  1. Update your TeX distribution (recommended)

or

  1. Use the old syntax, that is

    \setmainfont[
    Path = /home/gthomson/texmf/fonts/opentype/Fira/,
    BoldFont = FiraSans-Bold.otf,
    ItalicFont = FiraSans-Italic.otf,
    BoldItalicFont  = FiraSans-BoldItalic.otf]
    {FiraSans-Regular.otf}
    

    instead of

    \setmainfont{FiraSans-Regular.otf}[
    Path = /home/gthomson/texmf/fonts/opentype/Fira/,
    BoldFont = FiraSans-Bold.otf,
    ItalicFont = FiraSans-Italic.otf,
    BoldItalicFont  = FiraSans-BoldItalic.otf]
    

Note, however, that the path should contain a trailing /.


Just FYI, the new syntax has been introduced with fontspec v2.4 (2014/06/01), so, if you have an older version, you have to use the old syntax.