这是我的上一个问题关于在 mathtt 中设置 tt 字体。亨利·孟克在评论使用字体应该比使用字体系列更可取。因此,我尝试转换他的回答。结果是以下 MWE:
\starttypescript[test]
\definetypeface [test] [rm] [serif] [pagella]
\definetypeface [test] [tt] [mono] [firacode]
\definefontfallback [ttupper] [firacode] [uppercasenormal] [offset=uppercasemonospace,force=yes]
\definefontfallback [ttlower] [firacode] [lowercasenormal] [offset=lowercasemonospace,force=yes]
\definetypeface [test] [mm] [math] [pagella] [default] [fallbacks={ttlower,ttupper}]
\stoptypescript
\setupbodyfont [test,12pt]
\starttext
Test \type{Text} with $\mathtt{TEST}$
\stoptext
不幸的是,ConTeXt 不使用我指定的后备方案。后备机制如何与字体配合使用?
答案1
您只能使用 fallbacks \definefontsynonym
,因此您必须定义一个 typescript。当然,typescript 定义将放在大型项目的环境文件中。您还可以查看我的这个答案了解如何在系统范围内安装字体和 TypeScript。
\loadtypescriptfile[texgyre]
\definefontfallback [firaoverpagella] [file:FiraMono-Regular.otf] [uppercasenormal] [offset=uppercasemonospace,force=yes]
\definefontfallback [firaoverpagella] [file:FiraMono-Regular.otf] [lowercasenormal] [offset=lowercasemonospace,force=yes]
\starttypescript [mono] [firamono] [name]
\definefontsynonym [Mono] [file:FiraMono-Regular.otf]
\definefontsynonym [MonoBold] [file:FiraMono-Bold.otf]
\stoptypescript
\starttypescript [math] [firaoverpagella]
\definefontsynonym [MathRoman] [texgyrepagella-math] [features={math\mathsizesuffix,mathextra},fallbacks=firaoverpagella]
\stoptypescript
\starttypescript [pagella-with-fira]
\definetypeface [\typescriptone] [rm] [serif] [pagella] [default]
\definetypeface [\typescriptone] [ss] [sans] [pagella] [default]
\definetypeface [\typescriptone] [tt] [mono] [firamono] [default]
\definetypeface [\typescriptone] [mm] [math] [firaoverpagella] [default]
\quittypescriptscanning
\stoptypescript
\setupbodyfont [pagella-with-fira,12pt]
\starttext
Test \type{Text} with $\mathtt{TEST}$
\stoptext