1

Now, this is the exact same question as Is there a way to use different local font files for different font size in fontspec?, but is is left without a solution. @WillRobertson answered in a comment more than two years ago that he would fix this in fontspec, and I assume he has, since this is now addressed in sections 6.6 and 7.6 of the manual. But I still don't understand what I need to do in order to use the different fonts some font families provide for different optical sizes.


EDIT: See this answer to the original question for a solution.


Below is a MWE using EB Garamond. I've tried a dozen or so variants of this, but they all result in errors, the most common of which (as below), is that it can't find a font called EBGaramond.otf.

In this example, I've placed the EB Garamond fonts in a subdirectory called /fonts/.

\documentclass{article}
\usepackage{fontspec}
    \setmainfont{EBGaramond}[
        Path = ./fonts/,
        Extension = .otf,
        SizeFeatures =
        {
            {Size = {10.1-},
                UprightFont = *12-Regular,
                ItalicFont = *12-Italic},
            {Size = {-10.1},
                UprightFont = *08-Regular,
                ItalicFont = *08-Italic}
        },
        SmallCapsFeatures = {Letters = SmallCaps},
        Ligatures = {Common, TeX},
        Numbers = {Proportional, OldStyle}]
\begin{document}
Hello world
\end{document}

Error message:

luaotfload | db : Reload initiated (formats: otf,ttf,ttc,dfont); reason: "File not found: ./fonts/EBGaramond.otf.".

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
! 
! The font "EBGaramond" cannot be found.
Sverre
  • 20,729
  • To keep this place tidy and therefore easily searchable, it would seem better not to open a new, duplicate question, but to add a comment to the earlier one pinging Will Robertson. But I don’t see that sections 6.6 and 7.6 of the manual address the problem. – Thérèse Sep 12 '15 at 17:33
  • @Thérèse The fontspec readme says for v.2.4 that "SizeFeatures can now be nested inside ItalicFeatures (etc.) and behaves correctly. This has been a very long overdue bug!" – Sverre Sep 12 '15 at 17:37
  • Sure, but that doesn’t address the problem with local files. – Thérèse Sep 12 '15 at 17:37
  • @Thérèse I see your point, but judging by the somewhat vague comment @WillRobertson gave, that bug is the reason why SizeFeatures didn't work for local files. – Sverre Sep 12 '15 at 17:39
  • Then you should clarify your question. If the problem is with local files only, then the question is a duplicate. If it’s with fonts you’ve installed wherever your operating system wants them, then EB Garamond isn’t a good example, because it will use the right optical size automatically. If the problem is with an installed font that doesn’t select the right size automatically, then there’s a good answer at https://tex.stackexchange.com/a/223633/7883. – Thérèse Sep 12 '15 at 17:45
  • @Thérèse I don't think my question needs clarification. It's about local files only, as stated. The reason I'm making this a new question is because when the original question was made, no solution was feasible, and Will said it was due to a bug. Now that bug is supposed to be fixed, but I still can't figure out how to do it. Maybe I should've edited the original question instead? – Sverre Sep 12 '15 at 17:51
  • That’s not the bug that is supposed to be fixed. – Thérèse Sep 12 '15 at 17:54
  • @Thérèse I'm afraid we need to disagree on that. It finally dawned on me how to correctly read sections 6.6 and 7.6 of the fontspec manual, and I've added an answer to the original question to demonstrate how that bug fix enables the use of local font files for different optical sizes. – Sverre Sep 13 '15 at 10:01

0 Answers0