我想使用KP 字体用于我的文档中的数学运算。ConTeXt 可识别以下文件:
mtxrun --script fonts --list --all --pattern=kp
identifier familyname fontname filename subfont instances
kpcompanionitalic kpcompanion kpcompanionitalic jkplmitc.afm
kpcompanionmedium kpcompanion kpcompanionmedium jkpbnc.afm
kpcompanionmediumitalic kpcompanion kpcompanionmediumitalic jkpbitc.afm
kpcompanionnormal kpcompanion kpcompanionregular jkplmnc.afm
kpcompanionregular kpcompanion kpcompanionregular jkplmnc.afm
kpexpertitalic kpexpert kpexpertitalic jkplmite.afm
kpexpertmedium kpexpert kpexpertmedium jkpbne.afm
kpexpertmediumitalic kpexpert kpexpertmediumitalic jkpbite.afm
kpexpertnormal kpexpert kpexpertregular jkplmne.afm
kpexpertregular kpexpert kpexpertregular jkplmne.afm
kpitalic kp kpitalic jkplmit8a.afm
kplargesmallcapsmedium kplargesmallcaps kplargesmallcapsmedium jkpkbsc.afm
kplargesmallcapsnormal kplargesmallcaps kplargesmallcapsregular jkpkmsc.afm
kplargesmallcapsregular kplargesmallcaps kplargesmallcapsregular jkpkmsc.afm
kpmedium kp kpmedium jkpbn8a.afm
kpmediumitalic kp kpmediumitalic jkpbit8a.afm
sfkpnormal sfkp sfkpregular jkpssmn8a.afm
sfkpregular sfkp sfkpregular jkpssmn8a.afm
sfkpscexpmedium sfkpscexp sfkpscexpmedium jkpssbsce.afm
sfkpscexpnormal sfkpscexp sfkpscexpregular jkpssmsce.afm
sfkpscexpregular sfkpscexp sfkpscexpregular jkpssmsce.afm
sfkpscmedium sfkpsc sfkpscmedium jkpssbsc8a.afm
sfkpscnormal sfkpsc sfkpscregular jkpssmsc8a.afm
sfkpscregular sfkpsc sfkpscregular jkpssmsc8a.afm
ttkp ttkp ttkpmedium jkpttbn8a.afm
ttkpcompmedium ttkpcomp ttkpcompmedium jkpttbnc.afm
ttkpcompnormal ttkpcomp ttkpcompregular jkpttmnc.afm
ttkpcompregular ttkpcomp ttkpcompregular jkpttmnc.afm
ttkpexpmedium ttkpexp ttkpexpmedium jkpttbne.afm
ttkpexpnormal ttkpexp ttkpexpregular jkpttmne.afm
ttkpexpregular ttkpexp ttkpexpregular jkpttmne.afm
ttkpmedium ttkp ttkpmedium jkpttbn8a.afm
我不知道接下来该怎么做。我尝试过像这样设置字体:
\definefontfamily[font] [serif] [Baskervaldx]
\definefontfamily[font] [math] [KP]
\definefontfamily[font] [sans] [Baskervaldx]
\definefontfamily[font] [mono] [Latin Modern]
\setupbodyfont[font,10pt]
然而,编译时出现错误
Math error: parameter \Umathquad\displaystyle is not set
这帖子似乎表明这意味着 KP 字体没有附带数学字体,即使我能够使用 KP 字体在 LaTeX 中设置方程式。
这个问题并不新鲜:这邮件列表主题似乎处理了同样的问题,但我对讨论的理解不够深入,不知道是否有解决方案。是否可以使用 KP 字体在 ConTeXt 中排版方程式?
答案1
映射文本字体并不难。映射数学字体要难得多。下面是我的拙见。文件的内容kpfonts-math.lfg
可以在邮件列表中找到https://mailman.ntg.nl/pipermail/ntg-context/2014/076606.html。这里我给出一个简化的版本。
local mathencodings = fonts.encodings.math
return {
name = "kpfonts-math",
version = "1.00",
comment = "kpfonts, math part.",
author = "Chris",
copyright = "ConTeXt development team",
mathematics = {
mapfiles = {
"kpfonts.map",
"mkiv-base.map",
},
virtuals = {
["kpfonts-rm"] = { -- MathRoman
{ name = "file:jkpmn8a", features = "virtualmath", main = true },
{ name = "jkpmia", vector = "tex-mr", skewchar=0x7F },
{ name = "jkpmi", vector = "tex-mi", skewchar=0x7F },
{ name = "jkpmi", vector = "tex-it", skewchar=0x7F },
{ name = "jkpbn8a", vector = "tex-bf", skewchar=0x7F },
{ name = "jkpbmi", vector = "tex-bi", skewchar=0x7F },
{ name = "jkpsy", vector = "tex-sy", skewchar=0x30, parameters = true },
{ name = "jkpex", vector = "tex-ex", extension = true },
{ name = "jkpsya", vector = "tex-ma" },
{ name = "jkpsyb", vector = "tex-mb" },
},
["kpfonts-bf"] = { -- MathRomanBold
{ name = "file:jkpbn8a", features = "virtualmath", main = true },
{ name = "jkpbmia", vector = "tex-mr", skewchar=0x7F },
{ name = "jkpbmi", vector = "tex-mi", skewchar=0x7F },
{ name = "jkpbmi", vector = "tex-it", skewchar=0x7F },
{ name = "jkpbsy", vector = "tex-sy", skewchar=0x30, parameters = true },
{ name = "jkpbex", vector = "tex-ex", extension = true },
{ name = "jkpbsya", vector = "tex-ma" },
{ name = "jkpbsyb", vector = "tex-mb" },
}
}
}
}
\starttypescriptcollection [kpfonts]
\definefontfeature[kpslant][default][slant=0.167]
\starttypescript [serif] [kpfonts] [name]
\setups[font:fallback:serif]
\definefontsynonym [Serif] [file:jkpmn8a.pfb] [features=default]
\definefontsynonym [SerifItalic] [file:jkpmit8a.pfb] [features=default]
\definefontsynonym [SerifBold] [file:jkpbn8a.pfb] [features=default]
\definefontsynonym [SerifBoldItalic] [file:jkpbit8a.pfb] [features=default]
\definefontsynonym [SerifCaps] [file:jkpmsc8a.pfb] [features=default]
\definefontsynonym [SerifBoldCaps] [file:jkpbsc8a.pfb] [features=default]
\stoptypescript
\starttypescript [sans] [kpfonts] [name]
\setups[font:fallback:sans]
\definefontsynonym [Sans] [file:jkpssmn8a.pfb] [features=default]
\definefontsynonym [SansItalic] [file:jkpssmn8a.pfb] [features=kpslant]
\definefontsynonym [SansBold] [file:jkpssbn8a.pfb] [features=default]
\definefontsynonym [SansBoldItalic] [file:jkpssbn8a.pfb] [features=kpslant]
\definefontsynonym [SansCaps] [file:jkpssmsc8a.pfb] [features=default]
\definefontsynonym [SansBoldCaps] [file:jkpssbsc8a.pfb] [features=default]
\stoptypescript
\starttypescript [mono] [kpfonts] [name]
\setups[font:fallback:mono]
\definefontsynonym [Mono] [file:jkpttmn8a.pfb] [features=default]
\definefontsynonym [MonoItalic] [file:jkpttmn8a.pfb] [features=kpslant]
\definefontsynonym [MonoBold] [file:jkpttbn8a.pfb] [features=default]
\definefontsynonym [MonoBoldItalic] [file:jkpttbn8a.pfb] [features=kpslant]
\stoptypescript
\starttypescript [math] [kpfonts] [all]
\loadfontgoodies[kpfonts-math]
\definefontsynonym [MathRoman] [kpfontsrm@kpfonts-rm]
\definefontsynonym [MathRomanBold] [kpfontsbf@kpfonts-bf]
\stoptypescript
\starttypescript [kpfonts]
\definetypeface [\typescriptone] [rm] [serif] [kpfonts] [default]
\definetypeface [\typescriptone] [ss] [sans] [kpfonts] [default]
\definetypeface [\typescriptone] [tt] [mono] [kpfonts] [default]
\definetypeface [\typescriptone] [mm] [math] [kpfonts] [default]
\quittypescriptscanning
\stoptypescript
\stoptypescriptcollection
\defineenumeration
[theorem]
[text={Theorem},
style=sans,
title=yes,
titlestyle=italic,
distance=0pt,
titleleft={(},
titleright={).~},
alternative=serried,
width=fit]
% make the unmapped glyphs yourself
\define\iiiint{\mathop{\int\mkern-13mu\int\mkern-13mu\int\mkern-13mu\int}\intlimits}
\define\Vert{\mathord{|\mkern-1mu|}}
\setupbodyfont[kpfonts]
\starttext
\starttheorem[title={Residue theorem}]
Let $f$ be analytic in the region $G$ except for the isolated
singularities $a_1,a_2,\dots,a_m$. If $\gamma$ is a closed
rectifiable curve in $G$ which does not pass through any of the
points $a_k$ and if $\gamma\approx 0$ in $G$, then
\startformula
\frac{1}{2\pi i}\int\limits_{\gamma}f\left(x^{{\mathbf N}\in\mathbb{C}^{N\times 10}}\right) = \sum_{k=1}^m
n(\gamma;a_k){\mathrm Res}(f;a_k)\,.
\stopformula
\stoptheorem
\starttheorem[title={Maximum modulus}]
Let $G$ be a bounded open set in $\mathbb{C}$ and suppose that $f$
is a continuous function on $G^-$ which is analytic in $G$. Then
\startformula
\max\{|f(z)|\:z\in G^-\} = \max\{|f(z):z\in \partial G\}\,.
\stopformula
\stoptheorem
First some large operators both in text:
$\iiint\limits_{Q}f(x,y,z)\,{\mathrm d}x\,{\mathrm d}y\,{\mathrm d}z$
and
$\prod_{\gamma\in\Gamma_{\bar{C}}}\partial\left(\tilde{X}_\gamma\right)$;
and also on display
\startformula
\iiiint\limits_{Q}f(w,x,y,z)\,{\mathrm d}w\,{\mathrm d}x\,{\mathrm d}y\,{\mathrm d}z\leq\oint_{\partial Q} f^\prime\left(\max\left\{\frac{\Vert w\Vert}{\vert w^2+x^2\vert};\frac{\Vert z\Vert}{\vert y^2+z^2\vert};\frac{\Vert w\oplus z\Vert}{\vert x\oplus y\vert}\right\}\right)
\stopformula
\stoptext
当然,我没有完成你的所有工作,因此会有一些未映射的字形。我不会深入研究字体表来查找正确的映射。但初步看来,它看起来相当不错。