我有一种字体,具有一些光学尺寸,我想使用它。我尝试了两种解决方案(如下),但没有成功。如何使用本地字体的光学尺寸?我尝试的解决方案:
使用
\definefontfamily
,它给了我正确的基本替代方案(斜体,粗体等)并正确转换---
为破折号,但不支持根据大小更改字体(正如我从文档中理解的那样)。使用 typescript,它没有给我正确的替代方案(更多内容见下文)也没有转换
---
为长破折号。我无法理解如何以这种方式配置光学尺寸(尽管这似乎是推荐的方式)。
使用 TypeScript,普通斜体被转换为半粗体斜体。我在 TypeScript 上放置了半粗体声明,但没有在普通斜体中放置。我的 TypeScript 声明和用法:
\definebodyfontenvironment[default][em=italic]
\definebodyfontenvironment[12pt][interlinespace=4.2ex]
\definebodyfontenvironment[10pt][interlinespace=3.2ex]
\starttypescript [serif] [garamond]
\setups [font:fallback:serif]
\definefontsynonym [Garamond-Regular] [name:Garamond Premier Pro Regular]
\definefontsynonym [Garamond-Italic] [name:Garamond Premier Pro Italic]
\definefontsynonym [Garamond-Medium] [name:Garamond Premier Pro Medium]
\definefontsynonym [Garamond-Semibold] [name:Garamond Premier Pro Semibold]
\definefontsynonym [Garamond-Bold] [name:Garamond Premier Pro Bold]
\definefontsynonym [Garamond-MediumItalic] [name:Garamond Premier Pro Medium Italic]
\definefontsynonym [Garamond-SemiboldItalic] [name:Garamond Premier Pro Semibold Italic]
\definefontsynonym [Garamond-BoldItalic] [name:Garamond Premier Pro Bold Italic]
\stoptypescript
\starttypescript [serif] [garamond]
\definefontsynonym [Serif] [Garamond-Regular]
\definefontsynonym [SerifItalic] [Garamond-Italic]
\definefontsynonym [SerifSlanted] [Garamond-Italic]
\definefontsynonym [SerifMedium] [Garamond-Medium]
\definefontsynonym [SerifSemibold] [Garamond-Semibold]
\definefontsynonym [SerifBold] [Garamond-Bold]
\definefontsynonym [SerifMediumItalic] [Garamond-MediumItalic]
\definefontsynonym [SerifSemiboldItalic] [Garamond-SemiboldItalic]
\definefontsynonym [SerifBoldItalic] [Garamond-BoldItalic]
\definefontsynonym [SerifBoldSlanted] [Garamond-BoldItalic]
\stoptypescript
\starttypescript [garamond]
\definetypeface [garamond] [rm] [serif] [garamond] [default]
\stoptypescript
\usetypescript [serif] [garamond]
\usetypescript [garamond]
\setupbodyfont [garamond, 12pt]
提前致谢!
答案1
您必须使用字体 Goodies 才能使用设计尺寸。字体 Goodies 是 Lua 脚本,它返回一个包含有关字体的额外信息的表,并在运行时加载。有关 Goodies 的更多信息,请参阅第 5.4 章“Goodies”ConTeXt 字体 (PDF)。
garamond-premier.lfg
return {
name = "garamond-premier",
version = "1.00",
comment = "Goodies that complement Garamond Premier Pro.",
author = "Adobe",
copyright = "ConTeXt development team",
designsizes = {
["GaramondPremier-Regular"] = {
[ "4pt"] = "file:GaramondPremrPro-Capt.otf",
[ "5pt"] = "file:GaramondPremrPro-Capt.otf",
[ "6pt"] = "file:GaramondPremrPro-Capt.otf",
[ "7pt"] = "file:GaramondPremrPro.otf",
[ "8pt"] = "file:GaramondPremrPro.otf",
[ "9pt"] = "file:GaramondPremrPro.otf",
["10pt"] = "file:GaramondPremrPro.otf",
["11pt"] = "file:GaramondPremrPro.otf",
["12pt"] = "file:GaramondPremrPro.otf",
["13pt"] = "file:GaramondPremrPro-Subh.otf",
["14pt"] = "file:GaramondPremrPro-Subh.otf",
["15pt"] = "file:GaramondPremrPro-Subh.otf",
["16pt"] = "file:GaramondPremrPro-Subh.otf",
["17pt"] = "file:GaramondPremrPro-Subh.otf",
["18pt"] = "file:GaramondPremrPro-Subh.otf",
["19pt"] = "file:GaramondPremrPro-Subh.otf",
["20pt"] = "file:GaramondPremrPro-Disp.otf",
["21pt"] = "file:GaramondPremrPro-Disp.otf",
["22pt"] = "file:GaramondPremrPro-Disp.otf",
default = "file:GaramondPremrPro.otf",
},
["GaramondPremier-Italic"] = {
[ "4pt"] = "file:GaramondPremrPro-ItCapt.otf",
[ "5pt"] = "file:GaramondPremrPro-ItCapt.otf",
[ "6pt"] = "file:GaramondPremrPro-ItCapt.otf",
[ "7pt"] = "file:GaramondPremrPro-It.otf",
[ "8pt"] = "file:GaramondPremrPro-It.otf",
[ "9pt"] = "file:GaramondPremrPro-It.otf",
["10pt"] = "file:GaramondPremrPro-It.otf",
["11pt"] = "file:GaramondPremrPro-It.otf",
["12pt"] = "file:GaramondPremrPro-It.otf",
["13pt"] = "file:GaramondPremrPro-ItSubh.otf",
["14pt"] = "file:GaramondPremrPro-ItSubh.otf",
["15pt"] = "file:GaramondPremrPro-ItSubh.otf",
["16pt"] = "file:GaramondPremrPro-ItSubh.otf",
["17pt"] = "file:GaramondPremrPro-ItSubh.otf",
["18pt"] = "file:GaramondPremrPro-ItSubh.otf",
["19pt"] = "file:GaramondPremrPro-ItSubh.otf",
["20pt"] = "file:GaramondPremrPro-ItDisp.otf",
["21pt"] = "file:GaramondPremrPro-ItDisp.otf",
["22pt"] = "file:GaramondPremrPro-ItDisp.otf",
default = "file:GaramondPremrPro-It.otf",
},
["GaramondPremier-Bold"] = {
[ "4pt"] = "file:GaramondPremrPro-BdCapt.otf",
[ "5pt"] = "file:GaramondPremrPro-BdCapt.otf",
[ "6pt"] = "file:GaramondPremrPro-BdCapt.otf",
[ "7pt"] = "file:GaramondPremrPro-Bd.otf",
[ "8pt"] = "file:GaramondPremrPro-Bd.otf",
[ "9pt"] = "file:GaramondPremrPro-Bd.otf",
["10pt"] = "file:GaramondPremrPro-Bd.otf",
["11pt"] = "file:GaramondPremrPro-Bd.otf",
["12pt"] = "file:GaramondPremrPro-Bd.otf",
["13pt"] = "file:GaramondPremrPro-BdSubh.otf",
["14pt"] = "file:GaramondPremrPro-BdSubh.otf",
["15pt"] = "file:GaramondPremrPro-BdSubh.otf",
["16pt"] = "file:GaramondPremrPro-BdSubh.otf",
["17pt"] = "file:GaramondPremrPro-BdSubh.otf",
["18pt"] = "file:GaramondPremrPro-BdSubh.otf",
["19pt"] = "file:GaramondPremrPro-BdSubh.otf",
["20pt"] = "file:GaramondPremrPro-BdDisp.otf",
["21pt"] = "file:GaramondPremrPro-BdDisp.otf",
["22pt"] = "file:GaramondPremrPro-BdDisp.otf",
default = "file:GaramondPremrPro-Bd.otf",
},
["GaramondPremier-BoldItalic"] = {
[ "4pt"] = "file:GaramondPremrPro-BdItCapt.otf",
[ "5pt"] = "file:GaramondPremrPro-BdItCapt.otf",
[ "6pt"] = "file:GaramondPremrPro-BdItCapt.otf",
[ "7pt"] = "file:GaramondPremrPro-BdIt.otf",
[ "8pt"] = "file:GaramondPremrPro-BdIt.otf",
[ "9pt"] = "file:GaramondPremrPro-BdIt.otf",
["10pt"] = "file:GaramondPremrPro-BdIt.otf",
["11pt"] = "file:GaramondPremrPro-BdIt.otf",
["12pt"] = "file:GaramondPremrPro-BdIt.otf",
["13pt"] = "file:GaramondPremrPro-BdItSubh.otf",
["14pt"] = "file:GaramondPremrPro-BdItSubh.otf",
["15pt"] = "file:GaramondPremrPro-BdItSubh.otf",
["16pt"] = "file:GaramondPremrPro-BdItSubh.otf",
["17pt"] = "file:GaramondPremrPro-BdItSubh.otf",
["18pt"] = "file:GaramondPremrPro-BdItSubh.otf",
["19pt"] = "file:GaramondPremrPro-BdItSubh.otf",
["20pt"] = "file:GaramondPremrPro-BdItDisp.otf",
["21pt"] = "file:GaramondPremrPro-BdItDisp.otf",
["22pt"] = "file:GaramondPremrPro-BdItDisp.otf",
default = "file:GaramondPremrPro-BdIt.otf",
},
["GaramondPremier-Medium"] = {
[ "4pt"] = "file:GaramondPremrPro-MedCapt.otf",
[ "5pt"] = "file:GaramondPremrPro-MedCapt.otf",
[ "6pt"] = "file:GaramondPremrPro-MedCapt.otf",
[ "7pt"] = "file:GaramondPremrPro-Med.otf",
[ "8pt"] = "file:GaramondPremrPro-Med.otf",
[ "9pt"] = "file:GaramondPremrPro-Med.otf",
["10pt"] = "file:GaramondPremrPro-Med.otf",
["11pt"] = "file:GaramondPremrPro-Med.otf",
["12pt"] = "file:GaramondPremrPro-Med.otf",
["13pt"] = "file:GaramondPremrPro-MedSubh.otf",
["14pt"] = "file:GaramondPremrPro-MedSubh.otf",
["15pt"] = "file:GaramondPremrPro-MedSubh.otf",
["16pt"] = "file:GaramondPremrPro-MedSubh.otf",
["17pt"] = "file:GaramondPremrPro-MedSubh.otf",
["18pt"] = "file:GaramondPremrPro-MedSubh.otf",
["19pt"] = "file:GaramondPremrPro-MedSubh.otf",
["20pt"] = "file:GaramondPremrPro-MedDisp.otf",
["21pt"] = "file:GaramondPremrPro-MedDisp.otf",
["22pt"] = "file:GaramondPremrPro-MedDisp.otf",
default = "file:GaramondPremrPro-Med.otf",
},
["GaramondPremier-MediumItalic"] = {
[ "4pt"] = "file:GaramondPremrPro-MedItCapt.otf",
[ "5pt"] = "file:GaramondPremrPro-MedItCapt.otf",
[ "6pt"] = "file:GaramondPremrPro-MedItCapt.otf",
[ "7pt"] = "file:GaramondPremrPro-MedIt.otf",
[ "8pt"] = "file:GaramondPremrPro-MedIt.otf",
[ "9pt"] = "file:GaramondPremrPro-MedIt.otf",
["10pt"] = "file:GaramondPremrPro-MedIt.otf",
["11pt"] = "file:GaramondPremrPro-MedIt.otf",
["12pt"] = "file:GaramondPremrPro-MedIt.otf",
["13pt"] = "file:GaramondPremrPro-MedItSubh.otf",
["14pt"] = "file:GaramondPremrPro-MedItSubh.otf",
["15pt"] = "file:GaramondPremrPro-MedItSubh.otf",
["16pt"] = "file:GaramondPremrPro-MedItSubh.otf",
["17pt"] = "file:GaramondPremrPro-MedItSubh.otf",
["18pt"] = "file:GaramondPremrPro-MedItSubh.otf",
["19pt"] = "file:GaramondPremrPro-MedItSubh.otf",
["20pt"] = "file:GaramondPremrPro-MedItDisp.otf",
["21pt"] = "file:GaramondPremrPro-MedItDisp.otf",
["22pt"] = "file:GaramondPremrPro-MedItDisp.otf",
default = "file:GaramondPremrPro-MedIt.otf",
},
["GaramondPremier-Semibold"] = {
[ "4pt"] = "file:GaramondPremrPro-SmbdCapt.otf",
[ "5pt"] = "file:GaramondPremrPro-SmbdCapt.otf",
[ "6pt"] = "file:GaramondPremrPro-SmbdCapt.otf",
[ "7pt"] = "file:GaramondPremrPro-Smbd.otf",
[ "8pt"] = "file:GaramondPremrPro-Smbd.otf",
[ "9pt"] = "file:GaramondPremrPro-Smbd.otf",
["10pt"] = "file:GaramondPremrPro-Smbd.otf",
["11pt"] = "file:GaramondPremrPro-Smbd.otf",
["12pt"] = "file:GaramondPremrPro-Smbd.otf",
["13pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
["14pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
["15pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
["16pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
["17pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
["18pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
["19pt"] = "file:GaramondPremrPro-SmbdSubh.otf",
["20pt"] = "file:GaramondPremrPro-SmbdDisp.otf",
["21pt"] = "file:GaramondPremrPro-SmbdDisp.otf",
["22pt"] = "file:GaramondPremrPro-SmbdDisp.otf",
default = "file:GaramondPremrPro-Smbd.otf",
},
["GaramondPremier-SemiboldItalic"] = {
[ "4pt"] = "file:GaramondPremrPro-SmbdItCapt.otf",
[ "5pt"] = "file:GaramondPremrPro-SmbdItCapt.otf",
[ "6pt"] = "file:GaramondPremrPro-SmbdItCapt.otf",
[ "7pt"] = "file:GaramondPremrPro-SmbdIt.otf",
[ "8pt"] = "file:GaramondPremrPro-SmbdIt.otf",
[ "9pt"] = "file:GaramondPremrPro-SmbdIt.otf",
["10pt"] = "file:GaramondPremrPro-SmbdIt.otf",
["11pt"] = "file:GaramondPremrPro-SmbdIt.otf",
["12pt"] = "file:GaramondPremrPro-SmbdIt.otf",
["13pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
["14pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
["15pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
["16pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
["17pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
["18pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
["19pt"] = "file:GaramondPremrPro-SmbdItSubh.otf",
["20pt"] = "file:GaramondPremrPro-SmbdItDisp.otf",
["21pt"] = "file:GaramondPremrPro-SmbdItDisp.otf",
["22pt"] = "file:GaramondPremrPro-SmbdItDisp.otf",
default = "file:GaramondPremrPro-SmbdIt.otf",
},
},
}
type-imp-garamond-premier.mkiv
\starttypescriptcollection[garamond-premier]
\starttypescript [serif] [garamond-premier] [all]
\loadfontgoodies[garamond-premier]
\definefontsynonym [Serif] [GaramondPremier-Regular] [features=default,goodies=garamond-premier]
\definefontsynonym [SerifItalic] [GaramondPremier-Italic] [features=default,goodies=garamond-premier]
\definefontsynonym [SerifSlanted] [SerifItalic]
\definefontsynonym [SerifBold] [GaramondPremier-Bold] [features=default,goodies=garamond-premier]
\definefontsynonym [SerifBoldItalic] [GaramondPremier-BoldItalic] [features=default,goodies=garamond-premier]
\definefontsynonym [SerifBoldSlanted] [SerifBoldItalic]
\definefontsynonym [SerifMedium] [GaramondPremier-Medium] [features=default,goodies=garamond-premier]
\definefontsynonym [SerifMediumItalic] [GaramondPremier-MediumItalic] [features=default,goodies=garamond-premier]
\definefontsynonym [SerifMediumSlanted] [SerifMediumItalic]
\definefontsynonym [SerifSemibold] [GaramondPremier-Semibold] [features=default,goodies=garamond-premier]
\definefontsynonym [SerifSemiboldItalic] [GaramondPremier-SemiboldItalic] [features=default,goodies=garamond-premier]
\definefontsynonym [SerifSemiboldSlanted] [SerifSemiboldItalic]
\definefontsynonym [SerifCaps] [Serif] [features=smallcaps]
\stoptypescript
\starttypescript [garamond-premier]
\definetypeface [\typescriptone] [rm] [serif] [\typescriptone] [default] [designsize=auto]
\definetypeface [\typescriptone] [ss] [sans] [dejavu] [default] [rscale=0.8]
\definetypeface [\typescriptone] [tt] [mono] [dejavu] [default] [rscale=0.8]
\definetypeface [\typescriptone] [mm] [math] [dejavu] [default] [rscale=0.8]
\stoptypescript
\stoptypescriptcollection
您可能想要使用除 DejaVu 之外的无衬线字体、单声道字体和数学字体。我只是为了完整性才在这里添加的。您不应该遗漏其中任何一个,因为如果您尝试使用它们并且它们没有定义,就会发生奇怪的事情。
字体替代只能有两个字母,因为 ConTeXt 将使用它后面的任何内容作为大小说明符,就像b
中的一样\tfb
。
然后您可以通过以下方式在文档中使用它
\loadtypescriptfile[garamond-premier]
\definefontalternative[mf]
\definefontalternative[mi]
\definefontalternative[ms]
\definefontalternative[sf]
\definefontalternative[si]
\definefontalternative[ss]
\definebodyfont [default] [rm]
[tf=Serif sa 1,
bf=SerifBold sa 1,
it=SerifItalic sa 1,
sl=SerifSlanted sa 1,
bi=SerifBoldItalic sa 1,
bs=SerifBoldSlanted sa 1,
sc=SerifCaps sa 1,
%
mf=SerifMedium sa 1,
mi=SerifMediumItalic sa 1,
ms=SerifMediumSlanted sa 1,
%
sf=SerifSemibold sa 1,
si=SerifSemiboldItalic sa 1,
ss=SerifSemiboldSlanted sa 1]
\stoptypescript
\setupbodyfont[garamond-premier]
\setuppapersize [A4,landscape]
\starttext
\dorecurse{22}{
\switchtobodyfont[\recurselevel pt]
\recurselevel\
Regular
\italic{Italic}
\bold{Bold}
\bolditalic{Bold italic}
{\mf Medium}
{\mi Medium italic}
{\sf Semibold}
{\si Semibold italic}
\par
}
\stoptext
如您所见,这看起来并不是真正连续的。这是因为我猜测了不同设计尺寸应使用的值。在生产中,应该仔细微调这些值以实现更连续的行为。
输出pdffonts
确认所有字体都已嵌入。
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
EKDZXO+GaramondPremrPro-Capt CID Type 0C Identity-H yes yes yes 4 0
HXIZMD+GaramondPremrPro-ItCapt CID Type 0C Identity-H yes yes yes 5 0
YCEHGM+GaramondPremrPro-BdCapt CID Type 0C Identity-H yes yes yes 6 0
LXMWZN+GaramondPremrPro-BdItCapt CID Type 0C Identity-H yes yes yes 7 0
YSTBXJ+GaramondPremrPro-MedCapt CID Type 0C Identity-H yes yes yes 8 0
UZWASV+GaramondPremrPro-MedItCapt CID Type 0C Identity-H yes yes yes 9 0
BCZEUK+GaramondPremrPro-SmbdCapt CID Type 0C Identity-H yes yes yes 10 0
ULHHSI+GaramondPremrPro-SmbdItCapt CID Type 0C Identity-H yes yes yes 11 0
KYSIQC+GaramondPremrPro CID Type 0C Identity-H yes yes yes 12 0
ZQKUVZ+GaramondPremrPro-It CID Type 0C Identity-H yes yes yes 13 0
NEOZVY+GaramondPremrPro-Bd CID Type 0C Identity-H yes yes yes 14 0
JHIVFR+GaramondPremrPro-BdIt CID Type 0C Identity-H yes yes yes 15 0
EMFOVD+GaramondPremrPro-Subh CID Type 0C Identity-H yes yes yes 16 0
DAPJGX+GaramondPremrPro-ItSubh CID Type 0C Identity-H yes yes yes 17 0
NBZBXV+GaramondPremrPro-BdSubh CID Type 0C Identity-H yes yes yes 18 0
EEPVVZ+GaramondPremrPro-BdItSubh CID Type 0C Identity-H yes yes yes 19 0
DCVBES+GaramondPremrPro-MedSubh CID Type 0C Identity-H yes yes yes 20 0
KRRICW+GaramondPremrPro-MedItSubh CID Type 0C Identity-H yes yes yes 21 0
GNNEBG+GaramondPremrPro-SmbdSubh CID Type 0C Identity-H yes yes yes 22 0
NOXUKA+GaramondPremrPro-SmbdItSubh CID Type 0C Identity-H yes yes yes 23 0
OJMMRC+GaramondPremrPro-Disp CID Type 0C Identity-H yes yes yes 24 0
CHNDOC+GaramondPremrPro-ItDisp CID Type 0C Identity-H yes yes yes 25 0
MPPVHL+GaramondPremrPro-BdDisp CID Type 0C Identity-H yes yes yes 26 0
MMQBOJ+GaramondPremrPro-BdItDisp CID Type 0C Identity-H yes yes yes 27 0
AFGIHW+GaramondPremrPro-MedDisp CID Type 0C Identity-H yes yes yes 28 0
VYQMOL+GaramondPremrPro-MedItDisp CID Type 0C Identity-H yes yes yes 29 0
ZZMXKE+GaramondPremrPro-SmbdDisp CID Type 0C Identity-H yes yes yes 30 0
LUNAOE+GaramondPremrPro-SmbdItDisp CID Type 0C Identity-H yes yes yes 31 0
系统范围的安装
对于系统范围的安装,您可以将文件放入 ConTeXt 树中的适当位置。我只使用 ConTeXt 安装中的本地树。我显示了所有命令以及它们在我的机器上产生的输出。这些可能当然与您的不同。
首先我们得到本地树的路径,然后我们去那里。
$ mtxrun --resolve-path '$TEXMFLOCAL'
/opt/context/tex/texmf-local
$ cd /opt/context/tex/texmf-local
现在我们为打字稿文件创建一个目录。
$ mkdir -p tex/context/fonts/mkiv/
在这个新目录中,创建两个文件garamond-premier.lfg
和,type-imp-garamond-premier.mkiv
内容如上所述。
现在我们为 OpenType 字体文件创建一个目录。我遵循目录命名方案的惯例<foundry>/<fontname>
。
$ mkdir -p fonts/opentype/adobe/garamond-premier/
将所有 OpenType 文件放在那里。
因为我们在树中添加了新文件,所以我们必须重建文件名数据库。这是使用
$ mtxrun --generate
这将需要一点时间,并向终端打印大量消息。之后,您可以检查树中是否检测到新文件
$ mtxrun --find-file garamond-premier.lfg
/opt/context/tex/texmf-local/tex/context/fonts/mkiv/garamond-premier.lfg
$ mtxrun --find-file type-imp-garamond-premier.mkiv
/opt/context/tex/texmf-local/tex/context/fonts/mkiv/type-imp-garamond-premier.mkiv
$ mtxrun --find-file GaramondPremrPro.otf
/opt/context/tex/texmf-local/fonts/opentype/adobe/garamond-premier/GaramondPremrPro.otf
如果一切正常,您就可以排版文档了。打字稿应该会自动找到\setupbodyfont[garamond-premier]
(不需要\usetypescriptfile
或类似必要)。