[Tex/LaTex] EB Garamond, and fontspec for “optical bold” with small caps

ebgaramondfontsfontspec

This is somewhat a continuation of my EB Garamond (bold) small caps "suddenly" unavailable in lualatex? ; below, I had written some more details about this font for reference – but in brief, my question is:

Is there a way to set up fontspec with EB Garamond, so:

  • normal text (within a \newfontfamily command) uses EB Garamond 12;
  • then when text is bolded within the same \newfontfamily command (with \bfseries, \textbf) the font switches to EB Garamond 08;
  • and when small-caps \textsc is used, either a) Letters=SmallCaps is used, or b) EB Garamond SC font is used?

… such that it would also get rid of these warnings:

LaTeX Font Warning: Font shape `EU2/EBGaramond(0)/bx/n' undefined
(Font)              using `EU2/EBGaramond(0)/m/n' instead on input line 31.

… when compiling the following MWE, test.tex, with lualatex:

\PassOptionsToPackage{dvipsnames}{xcolor}

% compile with: lualatex test.tex

\documentclass[10pt,a4paper]{article}

  \makeatletter
  \newcommand{\name}[1]{\def\@name{#1}}
  \makeatother

  \usepackage[margin=2cm]{geometry}
  \geometry{left=1.25cm,right=1.25cm,top=1.25cm,bottom=1.25cm}

  \usepackage{fontspec}

  \newfontfamily\titlenamefont{EB Garamond}[Ligatures=TeX]

  % NOTE: `SmallCapsFeatures={Letters=SmallCaps}`, as per https://tex.stackexchange.com/questions/114223/, does not force small caps here, only `Letters=SmallCaps` does!?
  \newfontfamily\titlenamefontB{EB Garamond}[Ligatures=TeX,Letters=SmallCaps]

  \newfontfamily\titlenamefontC{EB Garamond 08 Regular}[OpticalSize=0,Letters=SmallCaps,Ligatures=TeX]

  \usepackage[hidelinks=true]{hyperref}

\begin{document}

  \name{\hspace{4em}\addfontfeature{LetterSpace=10.0}\textsc{Brazen Discovery}}

  \begingroup
    \makeatletter
      {\ifcsname titlenamefont\endcsname\titlenamefont\fi \Huge\bfseries{\@name}\par}
    \makeatother
  \endgroup\medskip

  \begingroup
    \makeatletter
      {\titlenamefontB \Huge\bfseries{\@name}\par}
    \makeatother
  \endgroup\medskip

  \begingroup
    \makeatletter
      {\titlenamefontC \Huge\bfseries{\@name}\par}
    \makeatother
  \endgroup\medskip

  Testing some normal paragraph text here...

\end{document}

The current output of this is:

Screenshot-test.pdf.png

Since my original post, I have done a fresh install of TexLive 2015, and realized the following: originally, I had wanted to achieve bolded small caps; probably by accident, I managed to use EB Garamond 08 instead of EB Garamond 12, which does look slightly more bolded, but is otherwise considered simply a different optical size (How do I use EB Garamond 08?) – while there is no proper "bold" in EB Garamond.

So, I ended up believing that this "bolding" is a result of using \bfseries – so when I tried compiling at a later time and couldn't see the "bolding", I wrote my original post, suspecting installation issues.

Now, at least I can state that I have these 10 .otf font files in ~/.local/share/fonts (Ubuntu 14):

$ ls -la ~/.local/share/fonts/EBGaramond*
-rw-r--r-- 1 user user 200656 Apr  8  2014 ~/.local/share/fonts/EBGaramond08-Italic.otf
-rw-r--r-- 1 user user 259968 Apr  8  2014 ~/.local/share/fonts/EBGaramond08-Regular.otf
-rw-r--r-- 1 user user 212492 Apr  8  2014 ~/.local/share/fonts/EBGaramond12-AllSC.otf
-rw-r--r-- 1 user user 298252 Apr  8  2014 ~/.local/share/fonts/EBGaramond12-Italic.otf
-rw-r--r-- 1 user user 495300 Apr  8  2014 ~/.local/share/fonts/EBGaramond12-Regular.otf
-rw-r--r-- 1 user user  60240 Apr  8  2014 ~/.local/share/fonts/EBGaramond-InitialsF1.otf
-rw-r--r-- 1 user user   5120 Apr  8  2014 ~/.local/share/fonts/EBGaramond-InitialsF2.otf
-rw-r--r-- 1 user user  78512 Apr  8  2014 ~/.local/share/fonts/EBGaramond-Initials.otf
-rw-r--r-- 1 user user 226840 Apr  8  2014 ~/.local/share/fonts/EBGaramondSC08-Regular.otf
-rw-r--r-- 1 user user 353364 Apr  8  2014 ~/.local/share/fonts/EBGaramondSC12-Regular.otf

… and they have been obtained directly from http://www.georgduffner.at/ebgaramond/download.html ; my ~/.fonts directory is now empty.

I have also done fc-cache:

$ fc-cache -f -v ; fc-list | grep aramond
...
fc-cache: succeeded
~/.local/share/fonts/EBGaramond12-Regular.otf: EB Garamond,EB Garamond 12:style=12 Regular,Regular
~/.local/share/fonts/EBGaramond12-Italic.otf: EB Garamond,EB Garamond 12:style=12 Italic,Italic
~/.local/share/fonts/EBGaramondSC12-Regular.otf: EB Garamond SC,EB Garamond SC 12:style=12 Regular,Regular
~/.local/share/fonts/EBGaramond08-Regular.otf: EB Garamond,EB Garamond 08:style=08 Regular,Normal,obyčejné,Standard,Κανονικά,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
~/.local/share/fonts/EBGaramond08-Italic.otf: EB Garamond,EB Garamond 08:style=08 Italic,Cursiva,kurzíva,kursiv,Πλάγια,Italic,Kursivoitu,Italique,Dőlt,Corsivo,Cursief,Kursywa,Itálico,Курсив,İtalik,Poševno,Etzana
~/.local/share/fonts/EBGaramond-InitialsF1.otf: EB Garamond Initials Fill1:style=Regular
~/.local/share/fonts/EBGaramond-InitialsF2.otf: EB Garamond Initials Fill2:style=Regular
~/.local/share/fonts/EBGaramondSC08-Regular.otf: EB Garamond SC,EB Garamond SC 08:style=08 Regular,Normal,obyčejné,Standard,Κανονικά,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
~/.local/share/fonts/EBGaramond12-AllSC.otf: EB Garamond 12 All SC:style=AllSC
~/.local/share/fonts/EBGaramond-Initials.otf: EB Garamond Initials:style=Regular

And this is how the font appears in fontmatrix:

Screenshot-Fontmatrix1.png

So, even if I have 10 .otf font files installed, I have only 6 entries in fontmatrix… So these entries here are I guess "font families", that is "EB Garamond" is one font family, "EB Garamond SC" is another?

This is what I get when I double-click the "EB Garamond" entry in fontmatrix:

Screenshot-Fontmatrix2.png

So, here I can see the entries (I guess) for EBGaramond08-Italic.otf, EBGaramond08-Regular.otf, EBGaramond12-Italic.otf, EBGaramond12-Regular.otf. And when I select the "08 Italic" button, I'm told that the current font is "EB Garamond 08 Italic".

I get something similar, when I click on "EB Garamond SC":

Screenshot-Fontmatrix3.png

The entries "08 Regular" and "12 Regular" probably represent EBGaramondSC08-Regular.otf and EBGaramondSC12-Regular.otf.

As a note, say LibreOffice Writes does not group these fonts, but each has a separate entry:

Screenshot-LibreOfficeWriter.png

Anyways, to repeat my question in other terms now: is there a way for setting up a \newfontfamily, say \titlenamefont, in fontspec, such that:

  • When {\titlenamefont \Huge{MYTEXT}} is used, the font rendered is "EB Garamond 12 Regular"
  • When {\titlenamefont \Huge\bfseries{MYTEXT}} is used, the font rendered is "EB Garamond 08 Regular" (without generating warnings in latex log about nonexisting bold face)
  • When {\titlenamefont \Huge\bfseries{\textsc{MYTEXT}}} is used, the font rendered is a) either "EB Garamond 08 Regular" with Letters=SmallCaps option; or b) "EB Garamond SC 08 Regular"
  • When {\titlenamefont \Huge{\textsc{MYTEXT}}} is used (so without bold), the font rendered is a) either "EB Garamond 12 Regular" with Letters=SmallCaps option; or b) "EB Garamond SC 12 Regular"

(Side question: in the above MWE, why does SmallCapsFeatures={Letters=SmallCaps} not generate any small caps with \textsc, and just {Letters=SmallCaps} does?)

Best Answer

There’s a free version of the EB Garamond family on GitHub that comes in different weights. It’s based on EB Garamond 12, though, not 8. You can download regular, bold, italic and bold italic into your project directory or a subdirectory. Just Loading EB Garamond with the Path option to this subdirectory should work.

Then, create your font family using the Path, Scale, BoldFont, and BoldItalicFont options to \newfontfamily. For example, [Scale = MatchUppercase, Ligatures = {Common, TeX}, BoldFont = EBGaramond08-bold.otf, BoldItalicFont = EBGaramond08-BoldItalic.otf] (If you have such fonts.) Use Scale=MatchUppercase to make the heights match, then whatever Ligatures, Numbers and other options you want. You might also need BoldFeatures and BoldItalicFeatures. If you’re loading the specific font files you downloaded into a directory yourself, you probably want to load them by filename with Extension = .otf.

If your copy of the bold font is recent, it should contain small caps already, and they should just work. If you need to load a separate font, you might need to set the BoldFeatures = { SmallCapsFont = ... } option as well.

There is a free version of a Garamond No8 with small caps at Arkandis.

Related Question