Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am a big lover of the EB-Garamond fonts by Georg Duffner. As of now, he has made two sets of font files, EB-Garamond-8 and EB-Garamond-12, respectively for “design size 8pt” and “design size 12pt”. Is there a way to make fontspec (and possibly unicode-math, too) use EB-Garamond-8 fonts for small sizes e.g. sub/superscripts, footnotes… and EB-Garamond-12 fonts for regular sizes when using local font files¹?

If I use only EBGaramond12, the following code works if I put the EBGaramond12-* .otf files in a fonts/ directory sibling to the .tex²


but if I try to adapt it to use the SizeFeatures options

        {Size={-12}, UprightFont=EBGaramond8-Regular, ItalicFont=EBGaramond8-Italic},
        {Size={12-}, UprightFont=EBGaramond12-Regular, ItalicFont=EBGaramond12-Italic, BoldFont=EBGaramond12-Bold}

Then the document won't compile and I get the following error. Using complete names instead of wildcarded ones changes nothing.

The key 'fontspec/UprightFont' is unknown and is being ignored.

¹ It means that using features that automagically select the right system fonts is not an option.

² the file structure is

├── fonts
│   ├── EBGaramond08-Italic.otf
│   ├── EBGaramond08-Regular.otf
│   ├── EBGaramond12-Bold.otf
│   ├── EBGaramond12-Italic.otf
│   └── EBGaramond12-Regular.otf
└── paper.tex
share|improve this question
yes, look into the documentation. – Herbert May 14 '13 at 13:09
@Herbert Actually using local font files instead of system fonts seems to break the SizeFeatures option. Or vice-versa. – Evpok May 14 '13 at 14:30
There is no need to put the font files into the TeX directory. However, if you are using XeTeX then there will be a problem if you have fonts installed twice, system dir and local tex dir. – Herbert May 15 '13 at 6:45
@Herbert I know, but I need to be able to distribute the project to people who might not have EBGaramond installed or not the same version So I need to use a local fonts/ directory – Evpok May 15 '13 at 6:59
From memory this is a (major) oversight in fontspec which I've been meaning to fix for a long time now… I hope that I can free up some cycles soon to look at it! – Will Robertson Jul 31 '13 at 7:45

3 Answers 3

up vote 4 down vote accepted

Since version 2.4 of fontspec, it has been possible to use different local fonts for different optical sizes, cf. the README.

The trick is to specify the different fonts with a Font option embedded under SizeFeatures, which in turn (and this is the crucial part) must be embedded under the options UprightFeatures, ItalicFeatures, and so on, cf. the fontspec manual under section 6.6.

Here's a minimal example:

        Path = ./fonts/,
        Extension = .otf,
        UprightFont = *12-Regular, % set EB Garamond 12 as default upright font
        UprightFeatures = {
            SizeFeatures = {
                {Size = -10.1,
                    Font = *08-Regular}, % use EB Garamond 08 for 10pt size and smaller
                {Size = 10.1-}}}, % use default upright font for larger than 10pt size
        ItalicFont = *12-Italic, % set EB Garamond 12 as default italic font
        ItalicFeatures = {
            SizeFeatures = {
                {Size = -10.1,
                    Font = *08-Italic}, % use EB Garamond 08 for 10pt size and smaller
                {Size = 10.1-}}}, % use default italic font for larger than 10pt size
        SmallCapsFeatures = {Letters = SmallCaps},
        Ligatures = {Common, TeX},
        Numbers = {Proportional, OldStyle}]

EB Garamond 08: The quick brown fox jumps over the lazy dog 1234567890

\textit{EB Garamond 08: The quick brown fox jumps over the lazy dog 1234567890}

EB Garamond 12: The quick brown fox jumps over the lazy dog 1234567890

\textit{EB Garamond 12: The quick brown fox jumps over the lazy dog 1234567890}


enter image description here

share|improve this answer
Please see this answer for how to use \large and variants correctly. Use {\large ...} instead of \large{...}, as they don't take any arguments; they are switches. – hooy Sep 13 at 10:06
+1. You can make the example clearer by removing SmallCapsFeatures = {Letters = SmallCaps} (unnecessary with EB Garamond), Ligatures = {Common, TeX} (on by default), and Numbers = {Proportional, OldStyle} (defaults in EB Garamond). – Thérèse Sep 13 at 17:54
@Thérèse I included them on purpose to demonstrate that features that apply globally to all the EB Garamond fonts don't need to be specified individually under options like UprightFeatures (the manual leads you to believe they do). I can edit my answer and make this explicit. – Sverre Sep 13 at 18:15
For purposes of demonstration, a feature that’s not on by default would be better. – Thérèse Sep 13 at 18:27

If you download the fonts from Georg Duffner’s site, the archive includes a file called README.xelualatex. It tells you to load the font with \setmainfont{EB Garamond} (not your \setmainfont{EBGaramond12}), and explains that the sizes will take care of themselves. It also explains how to turn off optical sizes if you like: \setmainfont[OpticalSize=0]{EB Garamond 12 Regular}.

share|improve this answer
In my case (and in @Evpoks, as evidenced by the comment), I have to include the fonts in the distributed content in case the end-user doesn't have them. This means I have to reference them by filename, so this is not an option. – You Jul 27 '13 at 10:08
I was just going to suggest using \directlua{fonts.names.scan(".")}, but that’s a neat trick which seems not to work any longer since TeX Live 2013. We need a lua expert to tell us how it goes now. – Thérèse Jul 27 '13 at 19:18
The question is clearer now with the footnotes, and I see that my answer doesn’t address your situation. However, I’ll leave the answer here anyway, because anyone who downloads EB Garamond from CTAN and not straight from Georg Duffner’s site is likely to be unaware of his explanations (the CTAN package being directed toward users of pdftex). – Thérèse Jul 31 '13 at 4:39

I still use the NFSS instead of fontspec. And NFSS has something for font sizes. I never used this feature, therefore can't suggest the exact syntax.

Below is my private NFSS-setup for Univers as an example. It uses the private encoding EUT1, you should change it to probably EU1.

\DeclareFontShape{EUT1}{univers}{m}{n}{ <-> "[UniversCom-55Roman.ttf]"}{}
\DeclareFontShape{EUT1}{univers}{m}{it}{ <-> "[UniversCom-55Oblique.ttf]"}{}
\DeclareFontShape{EUT1}{univers}{bx}{n}{ <-> "[UniversCom-65Bold.ttf]"}{}
\DeclareFontShape{EUT1}{univers}{bx}{it}{ <-> "[UniversCom-65Bold.ttf]:slant=0.2"}{}
\DeclareFontShape{EUT1}{univers}{bl}{n}{ <-> "[UniversCom-75Black.ttf]"}{}
share|improve this answer
I don't think this answers the question at all. – You Jul 26 '13 at 21:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.