I have the very same problem as described by someone once here, but not in a Lyx-Context, because of which the solution shown there seems not to work. Consider the following setup:
And in texfile I use some fonts from local font files:
\setmainfont[
Path = fonts/,
Ligatures = TeX,
UprightFont = Calibri.ttf,
BoldItalicFont= Calibri_Bold_Italic.ttf,
BoldFont = Calibri_Bold.ttf,
ItalicFont = Calibri_Italic.ttf
]{Calibri}
\newfontfamily[
Path = fonts/,
Ligatures = TeX,
UprightFont = Calibri_Light.ttf,
ItalicFont = Calibri_Light_Italic.ttf
]{Calibri_Light}
File structure is
/texfolder
|
--texfile.tex
--/fonts
|
--Calibri.ttf
--...etc
I render it with the following command (bash):
lualatex "\input{/texfolder/texfile.tex}"
That works if the command above is called from the folder from the texfolder. But if I call it from somewhere else, it fails on finding the fonts files, since the lualatex compiler searches for it in the folder from where it is called, not where the tex files lies. I can not write the absolute path in the tex-file because this is part of a program package and where it lies in the file system depends to the user.
What can I do?
- is there any chance to use \input@path in this context or an equivalent?
- or: is there a way to tell the lualatex command which working directory it has to use?
- or: Can I use somehow a variable for the path (instead of a relative path like fonts/) and provide this in the command?
Thank you for your help!
Edit 1:
Following some suggestions of @Ulrike Fischer i tried the following:
\usepackage[abspath]{currfile}
\message{path is \currfileabsdir}
\setmainfont[
Path = \currfileabsdir,
Ligatures = TeX,
UprightFont = calibri/Calibri.ttf,
BoldItalicFont= calibri/Calibri_Bold_Italic.ttf,
BoldFont = calibri/Calibri_Bold.ttf,
ItalicFont = calibri/Calibri_Italic.ttf
]{Calibri}
\newfontfamily[
Path = \currfileabsdir,
Ligatures = TeX,
UprightFont = calibri/Calibri_Light.ttf,
ItalicFont = calibri/Calibri_Light_Italic.ttf
]{Calibri_Light}
And run the command with -recorder. That seems to be the right trace, but still does not work. I get the following error, of which I have no idea what it could mean:
luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: "Font P not found.".
lualatex \def\pathprefix{..}\input{..}and then use \pathprefix in your settings. It is also possible to get the current path see e.g. http://tex.stackexchange.com/a/232413/2388 or http://tex.stackexchange.com/a/228928/2388. – Ulrike Fischer Mar 08 '17 at 15:56