3

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?

MS-SPO
  • 11,519
  • 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). – rallg Mar 18 '23 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.

    – 804b18f832fb419fb142 Mar 19 '23 at 00: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;"`

    – 804b18f832fb419fb142 Mar 19 '23 at 00:21
  • rm -rf ~/.texlive2022/texmf-var/luatex-cache/generic/fonts/otl/ as suggested here and rm -rf ~/.cache/texmf/fonts didn't help either. – 804b18f832fb419fb142 Mar 19 '23 at 00: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"

    – 804b18f832fb419fb142 Mar 19 '23 at 00:47
  • fc-list | sort | grep -i "EBGaramond shows that EBGaramond12-Italic contains fewer "attributes" than EBGaramond08-Italic:

    https://pastebin.com/raw/xDMiW7FK

    Maybe that's why one can find it with luaotfload manually, but not automatically.

    – 804b18f832fb419fb142 Mar 19 '23 at 01:05

2 Answers2

6

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

5

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}

Thérèse
  • 12,679
  • 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} }}]

    – 804b18f832fb419fb142 Mar 19 '23 at 01:37