# lualatex: Error when loading a font from a relative path [closed]

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 ()


• 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!


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?

## closed as unclear what you're asking by Moriambar, Troy, TeXnician, Stefan Kottwitz♦Jun 11 '17 at 10:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• 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 8: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 8:29
• 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 8:39
• You can check your luaotfload-tool version by running luaotfload-tool --version on the command line. – sodd Aug 24 '15 at 8: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 8:47