Font management in Xelatex and Lualatex

fontsluatexxetex

Referring to this thread: Xelatex vs Lualatex relatively to PetiteCaps

I solved the problem by proceeding as follows:

  • I kept both the Texlive version of EB Garamond (/usr/local/texlive/2021/texmf-dist/…) and the one, most recent, I installed by myself (/usr/local/share/fonts/…) ;

  • I cleared the cache of /var/cache/fontconfig/;

  • I deleted ~/.texlive2021;

  • I regenerated the cache with fc-cache -sfv.

At this point, Xelatex compiles in any case with the Texlive version: in fact the log file (compilation performed with the \ XeTeXtracingfonts = 1 option):

Requested font "EB Garamond / OT: script = latn; language = dflt;" at 10.00002pt -> /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/EBGaramond-Regular.otf

The same code, compiled with Luatex, instead uses my more recent version:

avail lists: 1: 1,2: 56,3: 12,4: 1,5: 23,6: 6,7: 194,9: 26,11: 20 </usr/local/share/fonts/opentype/EBGaramond/EBGaramond-Regular.otf>

Now the example file compiles correctly, with the PetiteCapital, with both compilers. What I still don't understand is why the two compilers use files in different directories without any indication.

In fact, I observe that, with the font cache regenerated – and without ~/.texlive2021 in my HOME – Xelatex starts immediately and compiles, while Lualatex first creates (with a few seconds of work) its own cache in ~/.texlive2021 and only then starts the compilation of the .tex file.

It would be interesting to know where the PATH indication, that the two compilers follow to manage the fonts, resides and the reasons for this different behavior .

Thank you

Best Answer

Lua(La)TeX uses its own font list which is generated by luaotfload-tool and which can be scanned by

bash-3.2$ luafindfont EBGaramond
We are using Lua 5.3
Looking for font "ebgaramond"
Check for file /usr/local/texlive/2021/texmf-var/luatex-cache/generic/names/luaotfload-names
 No.                       Fontname           Symbolic Name                                                                  Path
   1.            EBGaramond-Bold.otf              ebgaramond  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
   2.      EBGaramond-BoldItalic.otf              ebgaramond  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
   3.       EBGaramond-ExtraBold.otf              ebgaramond  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
   4. EBGaramond-ExtraBoldItalic.otf              ebgaramond  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
   5.        EBGaramond-Initials.otf      ebgaramondinitials  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
   6.          EBGaramond-Italic.otf              ebgaramond  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
   7.          EBGaramond-Medium.otf              ebgaramond  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
   8.    EBGaramond-MediumItalic.otf              ebgaramond  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
   9.         EBGaramond-Regular.otf              ebgaramond  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
  10.        EBGaramond-SemiBold.otf              ebgaramond  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
  11.  EBGaramond-SemiBoldItalic.otf              ebgaramond  /usr/local/texlive/2021/texmf-dist/fonts/opentype/public/ebgaramond/
  12.                 EBGaramond.otf              ebgaramond                                   /Users/voss/Library/Fonts/Garamond/
  13.       EBGaramond08-Regular.otf              ebgaramond                                   /Users/voss/Library/Fonts/Garamond/
  14.            EBGaramond08-SC.otf              ebgaramond                                   /Users/voss/Library/Fonts/Garamond/
  15.         EBGaramond12-AllSC.otf       ebgaramond12allsc                                   /Users/voss/Library/Fonts/Garamond/
  16.        EBGaramond12-Italic.otf              ebgaramond                                   /Users/voss/Library/Fonts/Garamond/
  17.       EBGaramond12-Regular.otf              ebgaramond                                   /Users/voss/Library/Fonts/Garamond/
  18.            EBGaramond12-SC.otf              ebgaramond                                   /Users/voss/Library/Fonts/Garamond/
  19.            EBGaramondAllSC.otf         ebgaramondallsc                                   /Users/voss/Library/Fonts/Garamond/
  20.             EBGaramondBold.otf              ebgaramond                                   /Users/voss/Library/Fonts/Garamond/
  21.       EBGaramondInitialsF1.otf ebgaramondinitialsfill1                                   /Users/voss/Library/Fonts/Garamond/
  22.       EBGaramondInitialsF2.otf ebgaramondinitialsfill2                                   /Users/voss/Library/Fonts/Garamond/
  23.           EBGaramondItalic.otf              ebgaramond                                   /Users/voss/Library/Fonts/Garamond/
  24.               EBGaramondSC.otf            ebgaramondsc                                   /Users/voss/Library/Fonts/Garamond/
bas

Xe(La)TeX uses fontconfig for searching the system fonts and the default kpsefind for the TeX fonts. This one will only be found by its filename and not the symbolic name whereas Lua(La)TeX will find TeX fonts also by its symbolic name, e.g. \setmainfont{EBGaramond}