Preamble: In a document I want to use EB Garamond for both text and maths and I don't want to install anything that doesn't come with TeX Live (i. e. no Garamond Math and no URW Garamond).
So here's my typescript thing for that (sorry for the long listing, it is the minimal working example i could make):
\definefontfeature
[eb-garamond-be-normal]
[default]
[onum=yes]
\starttypescriptcollection[ebgaramond-be]
\starttypescript [serif] [ebgaramond-be]
\loadfontgoodies[ebgaramond]
\setups[font:fallback:serif]
\definefontsynonym [Serif] [file:ebgaramond-regular] [features=eb-garamond-be-normal]
\definefontsynonym [SerifItalic] [file:ebgaramond-italic] [features=eb-garamond-be-normal]
\stoptypescript
\definefontfallback [ebgaramondmathtext] [file:EBGaramond12-Regular.otf] [digitsnormal] [force=yes]
\definefontfallback [ebgaramondmathtext] [file:EBGaramond12-Regular.otf] [lowercasenormal] [force=yes]
\definefontfallback [ebgaramondmathtext] [file:EBGaramond12-Regular.otf] [uppercasenormal] [force=yes]
\definefontfallback [ebgaramondmathtext] [file:EBGaramond12-Italic] [lowercasenormal] [offset=lowercaseitalic,force=yes]
\definefontfallback [ebgaramondmathtext] [file:EBGaramond12-Italic] [0x00068] [offset=0x0210E,force=yes]
\definefontfallback [ebgaramondmathtext] [file:EBGaramond12-Italic] [uppercasenormal] [offset=uppercaseitalic,force=yes]
\starttypescript [math] [ebgaramondandbonum]
\definefontsynonym [MathRoman] [texgyrebonummath] [features={math,mathextra},fallbacks=ebgaramondmathtext]
\stoptypescript
\starttypescript [ebgaramond-be]
\definetypeface[ebgaramond-be] [rm] [serif] [ebgaramond-be] [default] [designsize=auto]
\definetypeface[ebgaramond-be] [mm] [math] [ebgaramondandbonum] [default]
\stoptypescript
\stoptypescriptcollection
It does work:
\setupbodyfont[ebgaramond-be]
\starttext
text: {\it abcde123}
math: $abcde123$
\stoptext
but I want lining figures in math mode, instead of oldstyle ones. I tried to create separate feature set with lnum=yes,onum=no using \definefontfeature and add it alongside with {math,mathextra} to the main math font with no luck. Even worse: when I make lnum=yes for the main text font, it affects only text mode, leaving oldstyle figures in math mode:
Is it possible to set opentype features (like lnum, for example) to fallback fonts? Or, maybe, there are some other solutions?
Upd:
In the comments Metafox posted a solution. First there should be a fontfeature that does not rely on default
\definefontfeature [EBGM] [lnum=yes]
and then this feature can be referenced using *
after file name in the fallback definition:
\definefontfallback [ebgaramondmathtext] [file:EBGaramond12-Regular.otf*EBGM] [digitsnormal] [force=yes]
\definefontsynonym [EBGaramond-Regular] [file:ebgaramond12regular] [features=...]
) where you can apply the features and then load the font synonym in your fallback definition (e.g.\definefontfallback [ebgaramondmathtext] [EBGaramond-Regular] [...] [...]
).*
. The fallback for the digits in your example should be like this:\definefontfallback [ebgaramondmathtext] [file:ebgaramond12regular*eb-garamond-be-normal] [...] [...]
.\definefontfallback [ebgaramondmathtext] [file:ebgaramond12regular*eb-garamond-be-math] [digitsnormal] [force=yes]
digits do appear, but they are oldstyle, no matter what features are set ineb-garamond-be-math
base
mode for the features of your math fallbacks, e.g.\definefontfeature [ebgaramondmath] [lnum=yes]
and apply this feature set to your font files. Thedefault
features usenode
mode which doesn’t work in math mode.