2

I'm trying to use an otf file that is in the TEXMF tree, but another file with the same name is used instead.

I run lualatex from a locally installed TexLive 2019 on this file:

\documentclass{article}
\usepackage{fontspec}

\setmainfont [
  ItalicFont = LinLibertine_RI.otf,
  BoldFont = LinLibertine_RB.otf,
  ]{LinLibertine_R.otf}

\begin{document}
foo
\end{document}

and get the output

This is LuaTeX, Version 1.10.0 (TeX Live 2019) 
 restricted system commands enabled.
(./whichfont.tex
LaTeX2e <2018-12-01>

luaotfload | main : initialization completed in 0.076 seconds
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/l3pdfmode.def)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/tuenc.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
No file whichfont.aux.
[1{/usr/local/texlive/2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./whichfont.aux))
 410 words of node memory still in use:
   3 hlist, 1 vlist, 1 rule, 2 glue, 3 kern, 1 glyph, 5 attribute, 48 glue_spec
, 5 attribute_list, 1 write nodes
   avail lists: 2:15,3:4,4:1,5:22,6:1,7:16,9:7
</usr/share/texlive/texmf-dist/fonts/opentype/public/libertine/LinLibertine_R.o
tf>
Output written on whichfont.pdf (1 page, 2910 bytes).
Transcript written on whichfont.log.

As you can see files that are part of the Texlive 2019 installation are used, except that the file LinLibertine_R.otf is from another location. I would like to instead use the version that is in /usr/local/texlive/2019/texmf-dist/fonts/opentype/public/libertine (or rather the version that is in the TEXMF tree I use when TeXing the file).

I though this would do it:

$ luaotfload-tool --cache=erase
$ luaotfload-tool --update --prefer-texmf

but even after repeating lualatex after those commands it uses the same otf file. What can I do? (A kpsewhich LinLibertine_R.otf finds /usr/local/texlive/2019/texmf-dist/fonts/opentype/public/libertine/LinLibertine_R.otf as expected.)

I thought a workaround could be to use an explicit path, but actually, when adding

Path = /usr/local/texlive/2019/texmf-dist/fonts/opentype/public/libertine/

it still chooses the other file! (It matters what path I write though, because it complains it can't find the file if I give another directory!)

6
  • It is not. a good idea to install texlive in an own directory and also a texlive with the package manager of your Linux distribution. You should delete the files installed by the package manager.
    – user187802
    Jun 30, 2019 at 13:42
  • Does setting an explicit Path option in the \setmainfont directive help?
    – Mico
    Jun 30, 2019 at 13:57
  • @Mico I mention that as a possible workaround that didn't work at the end. (But even if it did work it's not a real solution anyway.)
    – pst
    Jun 30, 2019 at 14:02
  • 1
    What does your log-file say about the cache path? (look for "Lookup cache loaded from ..."). Jun 30, 2019 at 14:14
  • The output texmf-dist/fonts/opentype/public/libertine/LinLibertine_R.otf shows that the fonts used are from the texlive texmf tree.
    – user51830
    Jun 30, 2019 at 14:45

1 Answer 1

3

If you just want to prefer fonts in the texmf directory to system fonts, you can set the "location_precedence" of luaotfload:

\documentclass{article}
\usepackage{fontspec}
\directlua{
  fonts.names.set_location_precedence{
    "local", "texmf", "system" % The default is "local", "system", "texmf"
  }
}

\setmainfont [
  ItalicFont = LinLibertine_RI.otf,
  BoldFont = LinLibertine_RB.otf,
  ]{LinLibertine_R.otf}

\begin{document}
foo
\end{document}

This still uses luaotfload's database to find the font. The font loading system also allows to load a font as kpse:the_filname.otf to explicitly request the use of kpse, but this isn't exposed through fontspec.

4
  • 1
    I have been just considering if we could add an option to luaotfload.conf to set the order. But beside this: is /usr/share/texlive a "system" folder in this sense on linux? Jun 30, 2019 at 14:22
  • @UlrikeFischer That depends on how you set it in the fontconfig configuration files, but if it isn't the font wouldn't be found there in the first place. Jun 30, 2019 at 14:35
  • This gives me an error "[\directlua]:1: '}' expected near <eof>." What's wrong?
    – pst
    Jul 1, 2019 at 9:41
  • 1
    @pst That's fixed now. I used the wrong comment marker. If -- is used inside \directlua, the whole remaining \directlua argument is ignored, in this case including the }. Jul 1, 2019 at 9:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .