Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have problems trying to get new fonts to work when compiling with LuaLaTeX. I'm working on Mac and use TexShop (with the MacTeX package).

It goes like this:

I downloaded for example the Cardo font; I installed the Cardo font (it now appears in the Font Book); I tried to compile a simple text that goes like this:

\documentclass[11pt]{book}
\usepackage[no-math]{fontspec}    
\usepackage[frenchb]{babel}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmainfont{Cardo}

\begin{document}
Hello world!
\end{document}

After compiling I obtained the following error message:

luaotfload | Font names database loaded: /Users/juan/Library/texlive/2012/texmf
-var/luatex-cache/generic/names/otfl-names.lua
luaotfload | Updating the font names database:
luaotfload | Scanning TEXMF fonts...
luaotfload | Scanning OS fonts...
luaotfload | Font names database saved: %s 
: /Users/juan/Library/texlive/2012/texmf-var/luatex-cache/generic/names/otfl-names.lua

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

l.6 \setmainfont{Cardo}

? 
Process aborted
  • then I checked the otfl-names.lua and Cardo was missing;
  • I then added the Cardo folder font to this folder:

    /usr/local/texlive/2012/texmf-dist/fonts/
    
  • I executed the mkluatexfontdb -vvv command in a terminal;

  • I re-checked the otfl-names.lua and Cardo was finally there;

So I naturally tried to compile the text again after resetting the computer and (as you might guess by now) I obtained (again!) the following error message:

luaotfload | Font names database loaded: /Users/juan/Library/texlive/2012/texmf
-var/luatex-cache/generic/names/otfl-names.lua
luaotfload | Updating the font names database:
luaotfload | Scanning TEXMF fonts...
luaotfload | Scanning OS fonts...
luaotfload | Font names database saved: %s 
: /Users/juan/Library/texlive/2012/texmf-var/luatex-cache/generic/names/otfl-na
mes.lua

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

l.6 \setmainfont{Cardo}

? 
Process aborted

The thing is driving me crazy! I migrated to LuaLaTeX only because I was promised to be able to use almost any font with it. What am I doing wrong?

share|improve this question
    
Are you sure the authentic name the font is "cardo". Into font book you can probe the authentic name with Cmd i. –  jpayansomet Mar 21 '13 at 22:16
    
When dealing with newly downloaded fonts on a Mac system, I find it easiest to open the font file using the Font Book App (located i the Applications folder) and clicking on the "Install Font" button that's in the lower part of the window that FontBook opens. This method may become tedious if you're downloading dozens and dozens of fonts, but I find it to be completely failsafe. –  Mico Mar 21 '13 at 22:16
    
@jpayansomet Well, the Font Book says Cardo, but most of all, the "otfl-names.lua" says "Cardo"... –  jrojasqu Mar 21 '13 at 22:18
1  
Oh, one more thing: Don't install the fonts to a directory below /texmf-dist/2012, because those fonts won't migrate automatically when MacTeX2013 comes along. Much better to copy them to ~/Library/Fonts and let FontBook handle the "installation" business. –  Mico Mar 21 '13 at 22:21
1  
Don't install your own files in texmf-dist: use texmf-local. –  Martin Schröder Mar 22 '13 at 13:06

3 Answers 3

up vote 17 down vote accepted

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.
share|improve this answer
    
Thanks a lot! Well, it finally compiles! Though I first re-installed the font to "Computer" but it still didn't work. What worked for me was to set the path to /Library/Fonts/. Why is this so tricky?! Changing font for LaTeX is nothing less than dark art! Thanks again! –  jrojasqu Mar 22 '13 at 8:13
    
Well, it seems that the solution works for "Cardo" but not at all for "Baskerville" or "Garamond MT"... Knowing that 1)They all appear correctly in the otfl-names.lua file; 2)The path is absolute and the filenames are correct; 3)I erased, recreated and updated the otfl-names.lua` file; 4)I restarted the computer many times over; 5)Every single font I use is .ttf or .otf; 6)All the fonts are in the /Library/Fonts folder. I don't even know where to look from here... –  jrojasqu Mar 22 '13 at 12:11
    
@jrojasqu Hm, I'm using the texlive distribution downloaded from Macports --- maybe something is different about the configuration? I'm going to try downloading the Libre Baskerville font from here, and I'll post my setup step-by-step. Perhaps we can compare and see where the failure occurs. –  void-pointer Mar 22 '13 at 21:25
    
@jrojasqu I posted a step-by-step procedure that I used for installing the Libre Baskerville font. Perhaps if you try the same steps and post the error messages, we can see where things go wrong. One thing I might suspect is that you are having some kind of file permissions problem. –  void-pointer Mar 22 '13 at 21:50
1  
There is a problem with ttf fonts which was documented here. Basically, LuaLaTex used to not be able to run ttf fonts so they were all blacklisted. But if you follow the instructions on that post you can edit the blacklist file. –  jjewell May 20 '13 at 17:37

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!

share|improve this answer
    
Does this answer differ materially from the one provided by @nuttyaboutnatty? –  Mico Aug 29 at 7:54
    
Well the first part of the command which explicitly specifies OSFONTDIR was not required, so I thought I would a new simplified answer. –  John J. Camilleri Aug 29 at 8:17

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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