3

According to the fontspec package's user manual (2017/03/31 v2.6a, Section 5.1, p. 12)

Fonts known to LuaTEX [...] may be loaded by their standard names as you'd speak them out loud, such as Times New Roman or Adobe Garamond. [...]
The simplest example might be something like
\setmainfont{Cambria}[...]
[...] The 'font name' can be found in various ways, such as by looking in the name listed in a application like Font Book on Mac OS X.

My operating system is Mac OS X. The following screenshot shows the Times New Roman font in in my Font Book application.

The Times New Roman font in Font Book

The following screenshot shows the Avenir font name in my Font Book application.

The Avenir font in Font Book

The following LaTeX document sets the main font of the document to Times New Roman.

\documentclass{report}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\begin{document}
Hello, world!
\end{document}

Processing this document with the LuaLaTeX format (i.e. with the LuaLaTeX "engine") results in the following pdf, as expected:

Hello, world!

However, replacing 'Times New Roman' with 'Avenir' and reprocessing the document with the LuaLaTeX format results in no pdf, and the following error message:

ERROR: table index is nil.

--- TeX said ---

\scan_stop:
l.3 \setmainfont{Avenir}

--- HELP ---
From the .log file...

The lua interpreter ran into a problem, so the remainder of this lua chunk will be ignored.

What's the problem? Why doesn't the Avenir example work whereas the Times New Roman one does?


Operating System: macOS Sierra Version 10.12.5
MacTex distribution: MacTeX-2017
LuaTeX: Version 1.0.4

  • 1
    Try \setmainfont{Avenir light} – Huang_d Jun 10 '17 at 15:58
  • 2
    The font you showed us is not Avenir, it's Avenir Book. You have to add that "Book" because it identifies the font in the font family and probably corresponds to your font's name on disk. That's what fontspec can look for. – TeXnician Jun 10 '17 at 16:00
  • @TeXnician: Changing 'Avenir' to 'Avenir Book' works. So thanks. But I'd still like to know why simply writing 'Avenir' doesn't work, whereas writing 'Times New Roman' does work. Why did I not need to write 'Times New Roman Regular' in analogy to 'Avenir Book'? – Evan Aad Jun 10 '17 at 16:04
  • @TeXnician: And changing the font to either Courier or Courier Regular results in an error message. – Evan Aad Jun 10 '17 at 16:13
  • 1
    Font names are complicated beast and even more if there are collection of fonts with similar name. Try to find a name that works but don't try to hard to find a "logical" explanation why it works - there is always at least one odd font that doesn't fit the system. – Ulrike Fischer Jun 10 '17 at 16:20
4

I don't really know why LuaLaTeX is not able to associate Avenir Book to the upright font; with XeLaTeX it seems to go well.

Actually, if one looks closely, when XeLaTeX is used, the .ttc font file in the /System/Library/Fonts folder is used, not one of the files in /Library/Fonts. Perhaps this is the issue when LuaLaTeX comes into play, because luaotfload has a different strategy for choosing fonts.

For LuaLaTeX you need to specify the font names (at least in this case):

\documentclass{report}
\usepackage{fontspec}

\setmainfont{Avenir}[
  UprightFont=* Book,             % or Light
  ItalicFont=* Book Oblique,      % or Light Oblique
  BoldFont=* Black,               % or Medium
  BoldItalicFont=* Black Oblique, % or Medium Oblique
]

\begin{document}

Hello, world! \fontname\font

{\itshape Hello \fontname\font}

{\bfseries Hello \fontname\font}

{\bfseries\itshape Hello \fontname\font}

\end{document}

This would be needed also with XeLaTeX if you want Medium instead of Black.

Output with LuaLaTeX

enter image description here

Output with XeLaTeX

enter image description here

Output with XeLaTeX and just \setmainfont{Avenir}

enter image description here

  • How does XeTeX know automatically which fonts within the Avenir family to associate with Upright, Italic, Bold and BoldItalic? – Evan Aad Jun 10 '17 at 17:22
  • 1
    @EvanAad XeTeX uses the HarfBuzz and FontConfig libraries. – egreg Jun 10 '17 at 17:23
4

TLDR The font name is Avenir Book, Avenir is the font family name; Times New Roman is both the family and the main font name. Below how to tell them apart and where to find them using Mac FontBook


The names you are given in the font book, at least in the portion you shared, are not the real font names, as more the font family name or font family description; sometimes they match, but many times they don't. In fact you have many fonts under a single name as you can see from the screenshot.

What you are after are the enhanced bits, which you can see from the information panel. This is obtaining by the "i" shaped button on the top left. Sorry for the Italian. What you are after is the font complete name or, as an alternate, its Postscript name

enter image description here

enter image description here

You can see that Avenir is a family name which corresponds to no specific font, while Times New Roman has a specific font with the same name

  • 1
    Not really; Avenir Book is the name of a specific font in the Avenir family. – egreg Jun 10 '17 at 17:06
  • I've taken away the checkmark gave you because, as @egreg has pointed out, your answer seems to be incorrect in stating that the Avenirfont family's name is really Avenir Book. This point seems to be further demonstrated by @egreg's answer, which shows that XeTeX is able to make sense of the font family Avenir. Sorry for the flip-flop. – Evan Aad Jun 10 '17 at 17:30
  • @EvanAad I never (willingly) claimed that avenir book was the font name. It seemed the font you were looking for. If my wording failed me fine. You can trust egreg anyway – Moriambar Jun 10 '17 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.