luaotfload
uses a two level lookup when given a font name like Libertinus Serif
:
First the name is looked up in the cache to get the filename, in this case libertinusserif-regular.otf
, then a separate lookup is used to locate this file.
While the name lookup preferes files in the system directory, the filename lookup finds the font in the TeX tree.
To avoid this you have to avoid using the same filenmae for the font.
For example you can add the version number of Libertinus to the filenames while copying them into ~/.fonts
. Then just run luaotfload-tool -uf
for luaotfload
to pick up the changes. You do not have to run fc-cache
or other fontconfig commands, luaotfload
does not use fontconfig
, it just reads the same configuration files.
Another solution would be to patch luaotfload
. If the file luaotfload-database.lua
is patched with
diff --git a/usr/local/texlive/2018/texmf-dist/tex/luatex/luaotfload/luaotfload-database.lua b/luaotfload-database.lua
index 9c8c298..ca1fca6 100644
--- a/usr/local/texlive/2018/texmf-dist/tex/luatex/luaotfload/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -721,9 +721,9 @@ local get_font_file = function (index)
return true, basename, entry.subfont
end
else --- system, local
- local fullname = name_index.files.full [index]
+ local fullname = entry.fullpath
if lfsisfile (fullname) then
- return true, basename, entry.subfont
+ return true, fullname, entry.subfont
end
end
return false
@@ -1024,7 +1024,7 @@ local lookup_fontname = function (specification, name, style)
or face.fullname == name
or face.psname == name
then
- return face.basename, face.subfont
+ return face.fullpath, face.subfont
elseif face.familyname == name then
if typographicsubfamily == style
or subfamily == style
@@ -1043,10 +1043,10 @@ local lookup_fontname = function (specification, name, style)
end
end
if fallback then
- return fallback.basename, fallback.subfont
+ return fallback.fullpath, fallback.subfont
end
if lastresort then
- return lastresort.basename, lastresort.subfont
+ return lastresort.fullpath, lastresort.subfont
end
return nil, nil
end
the actual paths from the name cache are used directly and this fixes the problem. I haven't tested this a lot so it might have other consequences.
TEXMFLOCAL/fonts/opentype
? You'd need tomktexlsr
if you did this, I think. I don't know if this would work, mind, but it might be worth trying. You might also tryTEXMFHOME/fonts/opentype
, but I'm very leery of installing any fonts into the personal tree, even though the usual considerations don't apply here. (If you try TEXMFHOME, no need to runmktexlsr
.) I think it would be worth editing this question to make it LuaTeX specific since we think it is engine-specific. And maybe put that into the subject of the question.luaotfload-tool --dumpconf > luaotfload.conf
as it suggests. Result:...-dist/tex/luatex/luaotfload/luaotfload-configuration.lua:655: bad argument #3 to 'stringformat' (not a number in proper range)
I haven’t edited the configuration.