2

I'm trying to use Lato as my main font, but I would like to load it from my project folder. So I defined the following commands:

\newcommand*{\fontdir}[1][fonts/]{\def\@fontdir{#1}}
\fontdir

\newfontfamily\Lato[
  Path=\@fontdir,
  UprightFont=Lato-Regular.ttf,
  ItalicFont=Lato-Italic.ttf,
  BoldFont=Lato-Bold.ttf,
  BoldItalicFont=Lato-BoldItalic.ttf,
  NFSSFamily=latofont
]{Lato}

and set it as my main font

\setmainfont[Ligatures=TeX]{latofont}

but I get the following error:

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

I don't get it. Any help is appreciated.

Update

I succeeded to load it by defining:

\newfontfamily\Lato[
  Path=\@fontdir,
  NFSSFamily=latofont
]{Lato-Regular.ttf}
\setmainfont[Ligatures=TeX, Path=\@fontdir]{Lato-Regular.ttf}

but if I declare

\setmainfont[Ligatures=TeX, Path=\@fontdir]{latofont}

it does not work.

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

l.64 ...ont[Ligatures=TeX, Path=\@fontdir]{latofont}

? 

I guess the option NFSSFamily does not work, but you tell me. I'm using MacTex and LuaLatex:

$ lualatex -v
This is LuaTeX, Version 0.95.0 (TeX Live 2016)
11
  • How is Lato installed? As a system font? In a TeXmf directoty?
    – Bernard
    Aug 12, 2017 at 15:59
  • Lato is installed in the system, but I would like to add it from a local dir: \newcommand*{\fontdir}[1][fonts/]{\def\@fontdir{#1}} \fontdir. All the lato ttfs are in the fonts dir
    – Bertuz
    Aug 12, 2017 at 16:02
  • I don't see the point. Wouldn't it be as simple to use the system font?
    – Bernard
    Aug 12, 2017 at 16:07
  • Because I want to share it as a class (or I want to share that .tex as a project) and not everybody has that font installed. To simplify things that would help a lot.
    – Bertuz
    Aug 12, 2017 at 16:09
  • 1
    Do you have a GitHub account? If you do, log in and post an issue to the fontspec project there. This sounds like a bug in parsing the code, or perhaps a discrepancy between docs and code.
    – user139954
    Aug 12, 2017 at 16:23

1 Answer 1

3

You are overcomplicating things. If you want to set your main family to some font simply set it with \setmainfont:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}%[options if needed]

\begin{document}
This is the main (roman) family and it is in Pagella 
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .