How to properly install and use a new font with LuaLaTeX?

I came across the same problem as you when I first tried to use XeTeX. If you want fontspec to automatically find the path to the font and load it for you, then you need to have the font installed as a system font. On OS X, you can do this by navigating to Font Book -> Preferences and changing the "Default Installation Location" from "User" to "Computer". This should allow you to use the \setmainfont{<font name>} command without any prior configuration. For Linux distributions, you should consult the documentation for your desktop environment.

If you do not want to modify the set of system fonts, or you are working on a project in which you would like all of your resources to exist in one directory structure, you can specify the path to the font explicitly. For example, if you install Cardo as a user font (which is the default behavior on OS X), the font files should be copied to ~/Library/Fonts. Assuming that regular version of the font is supplied in a file called Cardo.ttf, you can load the font as follows. (Be sure to change <username> to your username).

\setmainfont[
    Path           = /Users/<username>/Library/Fonts/,
    Extension      = .ttf,
    Ligatures      = TeX
]{Cardo}

If you have bold, italic, and bold-italic variants of your font, you can use them by adding a few extra lines. In this example, I'm using a font called Crimson, which is supplied in the OTF format. The regular version of the font is called Crimson-Roman.otf; the bold, italic, and bold-italic variants are called Crimson-Bold.otf, Crimson-Italic.otf, and Crimson-BoldItalic.otf, respectively.

\setmainfont[
    Path           = /Users/<username>/Library/Fonts/,
    Extension      = .otf,
    Ligatures      = TeX,
    BoldFont       = Crimson-Bold,
    ItalicFont     = Crimson-Italic,
    BoldItalicFont = Crimson-BoldItalic
]{Crimson-Roman}

All of this information is available in the fontspec manual.

Edit

Since you still seem to be experiencing problems using other fonts with LuaTeX, I thought that posting my procedure step-by-step might help in identifying the problem. My texlive distribution is obtained from MacPorts; running lualatex -v returns the following: This is LuaTeX, Version beta-0.70.2-2013011221 (TeX Live 2012/MacPorts 2012_5).

  • I downloaded the Baskerville font from this link. The font files are called LibreBaskerville-Regular.otf, LibreBaskerville-Bold.otf, and LibreBaskerville-Italic.otf.
  • I installed the fonts as user fonts by double clicking the font files in Finder.
  • I created a file called baskerville.tex with the following contents. (I replaced my username by <username>).

\documentclass[11pt,a4paper]{article}
\usepackage{fontspec}
\setmainfont[
    Path           = /Users/<username>/Library/Fonts/,
    Extension      = .otf,
    Ligatures      = TeX,
    BoldFont       = LibreBaskerville-Bold,
    ItalicFont     = LibreBaskerville-Italic
]{LibreBaskerville-Regular}
\begin{document}
This is a test.
\end{document}

  • I compiled the file with the command lualatex baskerville.tex.

If your new fonts are in ~/.fonts and not being recognized by mkluatexfontdb, try this:

OSFONTDIR=${HOME}/.fonts:/usr/share/fonts//:/usr/share/texmf/fonts//   
mkluatexfontdb --force --verbose=-1 -vvv

On OSX, I was able to get things working in the following way:

  1. Install to default user location (/Users/john/Library/Fonts)
  2. mkluatexfontdb --force --verbose=-1 -vvv

That's all it took!