前言:在一份文档中,我想使用 EB Garamond 来处理文本和数学运算,并且我不想安装任何不附带 TeX Live 的东西(即没有 Garamond Math 和没有 URW Garamond)。
以下是我为此编写的打字稿(抱歉,列表太长,这是我能制作的最小的工作示例):
\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
它确实有效:
\setupbodyfont[ebgaramond-be]
\starttext
text: {\it abcde123}
math: $abcde123$
\stoptext
但我希望在数学模式下使用带线条的图形,而不是老式的图形。我尝试使用 \definefontfeature 创建 lnum=yes,onum=no 的单独功能集,并将其与 {math,mathextra} 一起添加到主数学字体中,但没有成功。更糟糕的是:当我为主文本字体设置 lnum=yes 时,它只会影响文本模式,而数学模式中则保留老式的图形:
是否可以将 opentype 功能(例如 lnum)设置为后备字体?或者,也许还有其他解决方案?
更新:
Metafox 在评论中发布了一个解决方案。首先应该有一个不依赖于default
\definefontfeature [EBGM] [lnum=yes]
然后可以*
在 fallback 定义中使用文件名引用此功能:
\definefontfallback [ebgaramondmathtext] [file:EBGaramond12-Regular.otf*EBGM] [digitsnormal] [force=yes]
答案1
数学模式中的特征仅当您处于模式时才可以更改base
,但在您的示例中,您根据default
使用node
模式的集合创建新特征。
实现此目的的最简单方法是创建一个没有模式设置的新功能,因为(数学模式下的符号不需要连字符等):
\definefontfeature [ebgaramond-math] [lnum=yes]
您的示例中的另一个问题是,您从未将该功能应用于数字的后备字体,为此,可以将该功能与命令中的字体文件一起应用\definefontfallback
,例如
\starttypescript [math] [ebgaramondandbonum]
\definefontfallback [ebgaramondmathtext] [file:EBGaramond12-Regular*ebgaramond-math] [digitsnormal] [force=yes]
\definefontsynonym [MathRoman] [texgyrebonummath] [features={math,mathextra},fallbacks=ebgaramondmathtext]
\stoptypescript
或者使用两步法,创建字体同义词,然后使用第三个参数设置特性,然后在字体后备中加载同义词,例如
\starttypescript [math] [ebgaramondandbonum]
\definefontsynonym [EBGaramondFallback-Regular] [file:EBGaramond12-Regular] [features=ebgaramond-math]
\definefontfallback [ebgaramondmathtext] [EBGaramondFallback-Regular] [digitsnormal] [force=yes]
\definefontsynonym [MathRoman] [texgyrebonummath] [features={math,mathextra},fallbacks=ebgaramondmathtext]
\stoptypescript
使用 EB Garamond 中的数字替换数学字体中的数字的完整代码如下所示:
\definefontfeature [ebgaramond-text] [default] [lnum=yes]
\definefontfeature [ebgaramond-math] [lnum=yes]
\starttypescript [serif] [ebgaramond-be]
\setups[font:fallback:serif]
\loadfontgoodies[ebgaramond]
\definefontsynonym [Serif] [file:ebgaramond-regular] [features=ebgaramond-text]
\definefontsynonym [SerifItalic] [file:ebgaramond-italic] [features=ebgaramond-text]
\stoptypescript
\starttypescript [math] [ebgaramondandbonum]
\definefontsynonym [EBGaramondFallback-Regular] [file:EBGaramond12-Regular] [features=ebgaramond-math]
\definefontfallback [ebgaramondmathtext] [EBGaramondFallback-Regular] [digitsnormal] [force=yes]
\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
\setupbodyfont[ebgaramond-be]
\starttext
text: {\it abcde123}
math: $abcde123$
\stoptext