6

I'm trying to load a .ttf from lualatex, which works fine when I place the .ttf in the same folder as the .tex file. However, for my project structure it would be beneficial to store .ttf files in a parent directory and load the fonts from e.g. ../Fonts/myCustomFont.ttf. From this answer I have learned that I can use the Path argument for instance with setmainfont. My minimal example looks like this:

\documentclass{article}

\usepackage{lipsum}
\usepackage{fontspec}

\setmainfont[Path = ../Fonts/]{agfarotissansserif.ttf}
% check: the required trailing slash is there

\begin{document}
\lipsum[1-3]
\end{document}

However, lualatex produces this fatal error with this example:

!LuaTeX error: cannot find OpenType font file for reading ()

I made the following observations:

  • Placing the agfarotissansserif.ttf file in the same directory (and removing the Path argument) works fine.
  • In order to check whether lualatex actually reads the .ttf I renamed it, so that I'm really loading from a non-existing path. In this case lualatex gives a "font not found" error. This means that the path argument seems to have an effect, and lualatex can find the file.
  • It does not seem to be a font problem. I get the same behavior with other .ttf files as well.

Overall I'm confused: It looks like lualatex actually does find the .ttf, and that it is capable of loading the font in general. Any ideas why I'm getting a fatal error nevertheless?

For the record: I did try ExternalLocation instead of Path and it looks like it behaves exactly the same. It also does not matter whether the font folder is a parent or a subdirectory. This trick of clearing the lua font cache did not help either.

My specs: Ubuntu 14.04 with Texlive 2013 from the Ubuntu repositories.

Update:

If I run luaotfload-tool --find=../Fonts/agfarotissansserif.ttf (from the subdirectory of the .tex, so that the path makes sense), I get:

luaotfload | resolve : Font "../Fonts/agfarotissansserif.ttf" found!
luaotfload | resolve : Resolved file name "/usr/share/fonts/truetype/padauk/Padauk-bold.ttf"

Another strange observation: I get the same output even if ../Fonts/agfarotissansserif.ttf does not exist.

In contrast, if I run luaotfload-tool --find=agfarotissansserif.ttf in the same folder as the .ttf, I get:

luaotfload | resolve : Font "agfarotissansserif.ttf" found!
luaotfload | resolve : Resolved file name "./agfarotissansserif.ttf"

In this case, if the .ttf does not exist, I get Cannot find "agfarotissansserif.ttf" in index as expected.

Does this explain the problem?

bluenote10
  • 1,479
  • For what it's worth I cannot seem to replicate this error. Your above code works for me on TeX Live 2015. Have you tried updating your distribution? – sodd Aug 24 '15 at 08:25
  • Are the fonts located ../Fonts directory known to Lua(La)TeX? (You could run the luaotfload-tool to find out...) Which TeX distribution, and which operating system, do you have on your system? – Mico Aug 24 '15 at 08:29
  • 1
    From this changelog it seems there was a fix for path handling in v2.4 of luaotfload-tool, which was released 2013/12/31. – sodd Aug 24 '15 at 08:39
  • You can check your luaotfload-tool version by running luaotfload-tool --version on the command line. – sodd Aug 24 '15 at 08:44
  • @nordev: What confuses me: If loading from a relative path was really broken in Texlive 2013, then I would have expected at least a comment in the famous load fonts that are in a ./fonts directory question. I have luaotfload-tool version "2.4-3" and luaotfload-tool --find=agfarotissansserif.ttf returns not found, if that is what @Mico meant. – bluenote10 Aug 24 '15 at 08:47
  • @bluenote10 Try luaotfload-tool --find ../Fonts/agfarotissansserif.ttf, if you are in the same directory as the .tex file, and the font is in the parent directory. – sodd Aug 24 '15 at 08:50
  • @nordev @Mico There is indeed a very strange difference when I resolve the font from the same or from a different directory -- see updated question. I have no idea why luaotfload suddenly resolves to this Padauk-bold.ttf. – bluenote10 Aug 24 '15 at 09:09

0 Answers0