2

I dowloaded EB Garamond from https://github.com/georgd/EB-Garamond/releases/tag/nightly and copied all fonts, .otf and .ttf to ~/.fonts/e

The typeface contains different font files for the optical sizes 08pt and 12pt:

enter image description here

However, if I create a document which should contain EBGaramond12-Italic and compile it with LuaLaTeX, my PDF reader only shows the following fonts:

enter image description here

%!TEX program = lualatex
\documentclass{article}
\usepackage{fontspec}
% https://tex.stackexchange.com/a/79783/38905
\setmainfont[%
SizeFeatures={%
    {Size={-12},
        Font=*08-Regular,
        ItalicFont=*08-Italic},
    {Size={12-},
        Font=*12-Regular,
        ItalicFont=*12-Italic}
},
]{EB Garamond}

\begin{document}
    \normalsize
    ABCDEFGHIJKLMNOPQRSTUVWXYZ
    
    \huge
    ABCDEFGHIJKLMNOPQRSTUVWXYZ
    
    \normalsize
    \textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
    
    \huge
    \textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ} 
\end{document}

This is how the PDF looks:

enter image description here

This was compiled with

This is LuaHBTeX, Version 1.15.0 (TeX Live 2022/TeX Live for SUSE Linux)
Development id: 7509

Why doesn't this work as expected and how can I work around this issue?

6
  • Good question! I do not see anything wrong with the code. Hopefully a more knowledgeable user will find this question and answer it. Meanwhile: Is there any chance that you have only some of the EBGaramond fonts installed in a different directory, and fontspec is finding that directory instead of where you placed the downloads? Did you try luaotfload-tool --cache=erase followed by luaotfload-tool -u ? Not sure if you need to precede that code with mktexlsr (probably not).
    – user287367
    Mar 18, 2023 at 23:56
  • I checked and they're not in /usr/share/fonts/truetype I noticed this in the lualatex output </home/username/.fonts/e/EBGaramond08-Italic.otf></home/username/.fonts/e/EBG aramond12-Regular.otf></home/username/.fonts/e/EBGaramond08-Regular.otf> luaotfload-tool did not fix this. Mar 19, 2023 at 0:04
  • In the log file, there is a difference between the normal and italic variant: (fontspec) This font family consists of the following NFSS (fontspec) series/shapes: (fontspec) (fontspec) - 'normal' (m/n) with NFSS spec.: (fontspec) <-12>"EBGaramond08-Regular:mode=node;script=latn;languag e=dflt;+tlig;"<12->"EBGaramond12-Regular:mode=node;script=latn;language=dflt;+t lig;" (fontspec) - 'italic' (m/it) with NFSS spec.: (fontspec) <->"EBGaramond/I:mode=node;script=latn;language=dflt;+tl ig;" Mar 19, 2023 at 0:21
  • rm -rf ~/.texlive2022/texmf-var/luatex-cache/generic/fonts/otl/ as suggested here and rm -rf ~/.cache/texmf/fonts didn't help either. Mar 19, 2023 at 0:36
  • If I manually search it, luaotftool does find it: $ luaotfload-tool --find=EBGaramond12-Regular luaotfload | resolve : Font "EBGaramond12-Regular" found! luaotfload | resolve : Resolved file name "/home/username/.fonts/e/EBGaramond12-Regular.otf" $ luaotfload-tool --find=EBGaramond12-Italic luaotfload | resolve : Font "EBGaramond12-Italic" found! luaotfload | resolve : Resolved file name "/home/username/.fonts/e/EBGaramond12-Italic.otf" Mar 19, 2023 at 0:47

2 Answers 2

5

The fontspec manual says about using SizeFeatures with ItalicFeatures:

Interaction with other features For SizeFeatures to work with ItalicFeatures, BoldFeatures, etc., and SmallCapsFeatures, a strict heirarchy(sic) is required:

UprightFeatures =
  {
    SizeFeatures =
      {
        {
          Size = -10,
          Font = ..., % if necessary
          SmallCapsFeatures = {...},
          ... % other features for this size range
        },
        ... % other size ranges
      }
  }

While not explicitly mentioned, the same principle applies to ItalicFont: The font shape (like italic or upright) is applied first, before size processing, so you need to follow specific orders when combining them.

Here you can do this by moving the italic fonts into the SizeFeatures of the ItalicFeatures:

%!TEX program = lualatex
\documentclass{article}
\usepackage{fontspec}
\setmainfont[%
  SizeFeatures={%
    {Size={-12}, Font=*08-Regular},
    {Size={12-}, Font=*12-Regular},
  },
  ItalicFeatures={%
    SizeFeatures={%
      {Size={-12}, Font=*08-Italic},
      {Size={12-}, Font=*12-Italic},
    },
  },
]{EB Garamond}

\begin{document}
    \normalsize
    ABCDEFGHIJKLMNOPQRSTUVWXYZ
    
    \huge
    ABCDEFGHIJKLMNOPQRSTUVWXYZ
    
    \normalsize
    \textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
    
    \huge
    \textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ} 
\end{document}

enter image description here

2
  • 1
    Thanks for the explanation. The code in your answer is the same as in my question, though. Mar 19, 2023 at 1:15
  • 2
    @804b18f832fb419fb142 Sorry, I pasted the wrong code. Fixed it now. Mar 19, 2023 at 2:53
4

Invoking \setmainfont{...} this way gives the desired result:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{ebgaramond}[
  UprightFeatures={
    SizeFeatures={
      {Size={12-},Font=ebgaramond12regular},
      {Size={-12},Font=ebgaramond08regular}
    }},
  ItalicFeatures={
    SizeFeatures={
      {Size={12-},Font=ebgaramond12italic},
      {Size={-12},Font=ebgaramond08italic}
    }}]
\begin{document}
\normalsize
ABCDEFGHIJKLMNOPQRSTUVWXYZ

\huge
ABCDEFGHIJKLMNOPQRSTUVWXYZ

\normalsize
\textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}

\huge
\textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\end{document}
1
  • Thanks, this works. Even when one specifies the fonts like this: [ UprightFeatures={ SizeFeatures={ {Size={12-},Font=*12-Regular}, {Size={-12},Font=*08-Regular} }}, ItalicFeatures={ SizeFeatures={ {Size={12-},Font=*12-Italic}, {Size={-12},Font=*08-Italic} }}] Mar 19, 2023 at 1:37

You must log in to answer this question.

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