8

In my TeX Live 2018 installation on Linux, I want to replace the Libertinus fonts shipped with TeX Live by their latest GitHub build. If they are used in LuaLaTeX e.g. via

\usepackage{fontspec}
\setmainfont{Libertinus Serif}

the new version should be used automatically. It seems (thanks to Thérèse) that in older versions of TeX Live it was sufficient to place them in a system font folder like ~/.fonts/. This does no longer work in TeX Live 2018. Also the local tree /usr/local/texlive/texmf-local/fonts/ does not work.

Please also include other steps required like running commands to update font caches and such.

It is not important to me, if the old versions are stil installed or deleted, I just don't want to use them anymore.

32
  • 2
    Which OS do you use?
    – TeXnician
    May 31, 2018 at 8:42
  • @TeXnician I am using Linux. (Manjaro)
    – user157036
    May 31, 2018 at 8:51
  • have you run an update on the FNDB?
    – naphaneal
    May 31, 2018 at 11:10
  • 1
    Have you tried installing the fonts into TEXMFLOCAL/fonts/opentype? You'd need to mktexlsr if you did this, I think. I don't know if this would work, mind, but it might be worth trying. You might also try TEXMFHOME/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 run mktexlsr.) 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.
    – cfr
    Jun 3, 2018 at 3:28
  • 1
    @cfr Hmmm. Have just been reading the man page for luaotfload-tool, and tried to look at the current configuration by running 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.
    – Thérèse
    Jun 3, 2018 at 4:35

2 Answers 2

4
+50

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.

18
  • Works fine. I will maybe wait for the other participants to confirm that it works for them aswell and then accept and award you the bounty.
    – user157036
    Jun 3, 2018 at 13:34
  • 1
    This is not a good solution. What if I want to use files in /usr/share/fonts in preference to those in TL? There is then no way to achieve this because the order is not configurable and I can't just rename files installed by my distro's package manager. Even if that was an OK thing to do, it would be undone every time the font package is updated. This will work for @Thérèse, where the concern is with a personal fonts directory, but it is no good for the standard case.
    – cfr
    Jun 4, 2018 at 2:33
  • 1
    @cfr Bonkers that the change wasn’t announced either; I wonder whether it was unintended and may be undone soon?
    – Thérèse
    Jun 4, 2018 at 2:39
  • 1
    @cfr I don’t see a report at github.com/lualatex/luaotfload/issues — but maybe a report will emerge from this question once it’s been tidied up.
    – Thérèse
    Jun 4, 2018 at 2:45
  • 2
    @cfr I added a patch which would prefer fonts in the system font directories without renaming. After the change even set_location_preference is respected... Jun 4, 2018 at 8:15
4

When I (on windows) have a font in more than one locations, all locations are in the luaotfload-names.lua. I have some doubts (but testing is not easy) that the order in which this font locations are used is well defined (tables in lua don't have a well defined order).

So I would avoid to have more than one copy of a font in accessible locations.

This means for a font coming via texlive that I would either

  • deinstall the original font package
  • or blacklist the original fonts in a (local) luaotfload-blacklist.cnf

For the second variant:

  • Add e.g.

     d:/texlive/2018/texmf-dist/fonts/opentype/public/libertinus/libertinusserif-regular.otf
    

    to a luaotfload-blacklist.cnf e.g. in texmf-local/tex/luatex/luaotfload

  • Delete the luaotfload-names.lua.gz and luc

  • Delete also the lua and/luc-files from the font in \texlive\2018\texmf-var\luatex-cache\generic\fonts\otl (they contain pathes too)

  • Recreate the database with luaotfload-tool -uf.

This imho should blacklist the font. Imho it is sadly not possible to blacklist complete directories.

1
  • @MarcelKrüger on Windows the ["local"] and the ["system"] fields are empty on this pc. All entries are in the texmf field. And the keys are unique, but e.g. ibmplexsans.r maps to an index number which is one of the clones I placed in various locations but it is quite unclear why this index number was choosen. Jun 4, 2018 at 12:19

You must log in to answer this question.