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.ttffile in the same directory (and removing thePathargument) 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?
../Fontsdirectory known to Lua(La)TeX? (You could run theluaotfload-toolto find out...) Which TeX distribution, and which operating system, do you have on your system? – Mico Aug 24 '15 at 08:29luaotfload-tool, which was released 2013/12/31. – sodd Aug 24 '15 at 08:39luaotfload-toolversion by runningluaotfload-tool --versionon the command line. – sodd Aug 24 '15 at 08:44luaotfload-tool version "2.4-3"andluaotfload-tool --find=agfarotissansserif.ttfreturns not found, if that is what @Mico meant. – bluenote10 Aug 24 '15 at 08:47luaotfload-tool --find ../Fonts/agfarotissansserif.ttf, if you are in the same directory as the.texfile, and the font is in the parent directory. – sodd Aug 24 '15 at 08:50Padauk-bold.ttf. – bluenote10 Aug 24 '15 at 09:09