我下载了 Times New Roman PS 字体供 ConTeXT (luatex) 使用。运行后mtxrun --script font --list --all pattern=timesnewroman*
得到以下结果:
timesnewromanbold timesnewroman timesnewromanpsboldmt /Users/javier/.fonts/TimesNewRomanPSMT/TimesNewRomanPS-BoldMT - Times New Roman - Bold.ttf
timesnewromanbolditalic timesnewroman timesnewromanpsbolditalicmt /Users/javier/.fonts/TimesNewRomanPSMT/TimesNewRomanPS-BoldItalicMT - Times New Roman - Bold Italic.ttf
timesnewromanitalic timesnewroman timesnewromanpsitalicmt /Users/javier/.fonts/TimesNewRomanPSMT/TimesNewRomanPS-ItalicMT - Times New Roman - Italic.ttf
timesnewromannormal timesnewroman timesnewromanpsitalicmt /Users/javier/.fonts/TimesNewRomanPSMT/TimesNewRomanPS-ItalicMT - Times New Roman - Italic.ttf
timesnewromanpsbolditalicmt timesnewroman timesnewromanpsbolditalicmt /Users/javier/.fonts/TimesNewRomanPSMT/TimesNewRomanPS-BoldItalicMT - Times New Roman - Bold Italic.ttf
timesnewromanpsboldmt timesnewroman timesnewromanpsboldmt /Users/javier/.fonts/TimesNewRomanPSMT/TimesNewRomanPS-BoldMT - Times New Roman - Bold.ttf
timesnewromanpsitalicmt timesnewroman timesnewromanpsitalicmt /Users/javier/.fonts/TimesNewRomanPSMT/TimesNewRomanPS-ItalicMT - Times New Roman - Italic.ttf
timesnewromanpsmt timesnewromanpsmt timesnewromanpsmt /Users/javier/.fonts/TimesNewRomanPSMT/TimesNewRomanPSMT.ttf
timesnewromanpsmtnormal timesnewromanpsmt timesnewromanpsmt /Users/javier/.fonts/TimesNewRomanPSMT/TimesNewRomanPSMT.ttf
timesnewromanpsmtregular timesnewromanpsmt timesnewromanpsmt /Users/javier/.fonts/TimesNewRomanPSMT/TimesNewRomanPSMT.ttf
我的设置如下:
% Enable Unicode fonts
\enableregime[utf]
% Enable Capital Letter use
\setupcapitals[sc=yes]
\starttypescript [serif] [timesnewromanps]
\definefontsynonym [Serif] [name:timesnewromanpsmtregular]
\definefontsynonym [SerifBold] [name:timesnewromanpsboldmt]
\definefontsynonym [SerifBoldItalic] [name:timesnewromanpsbolditalicmt]
\definefontsynonym [SerifItalic] [name:timesnewromanpsitalicmt]
\definefontsynonym [SerifCaps] [name:timesnewromanpsmtregular]
\stoptypescript
\definetypeface [timesnewromanps] [rm] [serif] [timesnewromanps] [default] [encoding=default]
\definebodyfont [default] [rm]
[tf=Serif sa 1,
bf=SerifBold sa 1,
it=SerifItalic sa 1,
bi=SerifBoldItalic sa 1,
sc=SerifCaps sa 1]
\usetypescript[serif][timesnewromanps]
\setupbodyfont[timesnewromanps,rm,12pt]
\definefont[TitleFont][Serif at 24pt]
\setuphead[title,chapter,section,subsection,subsubsection][align={flushleft, nothyphenated, verytolerant}]
\setuphead[title][style=TitleFont]
\setuphead[section][number=no, style=\ss\tfc]
\setuphead[subsection][number=no, style=\ss\tfb]
\setuphead[subsubsection][number=no, style=\ss\tfa]
\setupoutput[pdftex]
\setupcaptions[
location=top,
width=fit,
minwidth=fit,
number=no,
align=middle,
headstyle=\it,
style=\it,
]
ConTeXt 识别该字体并使用它打印文档,但它不会显示斜体、粗体或标题、章节等的字体类型。
毫无疑问,我的配置有些错误。如果您能帮助我,我将不胜感激。
非常感谢。
答案1
在您的问题中,您说“使用 ConTeXT (luatex)”,由此我推断您使用的是 ConTeXt MkIV。但您混淆了 MkII 和 MkIV 的概念。首先,以下陈述
\enableregime[utf]
\setupoutput[pdftex]
在 MkIV 中什么都不做,因为默认编码已经是 UTF-8,输出始终是 PDF。
接下来,定义衬线字体,timesnewromanps
但不定义无衬线、单衬线或数学字体。当您尝试用无衬线字体排版章节标题时,这就是问题所在。由于没有加载无衬线字体,ConTeXt 将只使用最后加载的字体,即 12pt 的衬线字体。要解决这个问题,您必须加载这些附加字体。在这里,我只使用modern
加载拉丁现代字体的打字稿。
我还做了一些小优化。
添加
\setups[font:fallback:serif]
到serif
打字稿允许 ConTeXt 从默认字体中加载缺失的字符(如果它们在那里定义的话)。所有
\definetypeface
语句都打包到以 结尾的打字稿中\quittypescriptscanning
。这告诉 ConTeXt 此时所有字体都已加载,可以提前退出。您也可以不用说,而
\ss\tfa
使用简写\ssa
。
\starttypescript [serif] [timesnewromanps]
\setups[font:fallback:serif]
\definefontsynonym [Serif] [name:timesnewromanpsmt]
\definefontsynonym [SerifBold] [name:timesnewromanpsboldmt]
\definefontsynonym [SerifBoldItalic] [name:timesnewromanpsbolditalicmt]
\definefontsynonym [SerifItalic] [name:timesnewromanpsitalicmt]
\definefontsynonym [SerifCaps] [name:timesnewromanpsmtregular]
\stoptypescript
\starttypescript [timesnewromanps]
\definetypeface [\typescriptone] [rm] [serif] [timesnewromanps] [default]
\definetypeface [\typescriptone] [ss] [sans] [modern] [default]
\definetypeface [\typescriptone] [tt] [mono] [modern] [default]
\definetypeface [\typescriptone] [mm] [math] [modern] [default]
\quittypescriptscanning
\stoptypescript
\setupbodyfont [timesnewromanps,rm,12pt]
\definefont [TitleFont] [Serif at 24pt]
\setuphead
[title,chapter,section,subsection,subsubsection]
[align={flushleft, nothyphenated, verytolerant}]
\setuphead [title] [style=TitleFont]
\setuphead [section] [number=no, style=\ssc]
\setuphead [subsection] [number=no, style=\ssb]
\setuphead [subsubsection] [number=no, style=\ssa]
\setupcaptions
[location=top,
width=fit,
minwidth=fit,
number=no,
align=middle,
headstyle=\it,
style=\it]
\starttext
\starttitle[title={Test}]
\startsection[title={Knuth}]
\samplefile{knuth}
\stopsection
\stoptitle
\stoptext
答案2
图像亨利的答案似乎缺少 fi 和 fl 连字符,因此这里对他的答案进行了一个小的补充,厚颜无耻地抄袭自Hans Hagen 为邮件列表撰写的内容。我假设 Times New Roman 没有任何其他连字符。
将以下内容放在第一个之前\starttypescript
(请注意,它使用 string.utf8character() 来以 ascii 安全方式表示 fi 和 fl):
\startluacode
fonts.handlers.otf.addfeature {
name = "liga",
type = "ligature",
data = {
[string.utfcharacter(0xFB01)] = { "f", "i" },
[string.utfcharacter(0xFB02)] = { "f", "l" },
}
}
\stopluacode
\definefontfeature [timesnewromanps-preset] [
mode=node,kern=yes,protrusion=quality,expansion=quality,
script=latn,language=dflt,
trep=yes,tlig=yes,liga=yes]
%% In case you want to turn off ligatures: {\feature[+][f:nolig]fi fl}
\definefontfeature [f:nolig] [liga=no]
[features=timesnewromanps-preset]
现在在每个 \definefontsynonym 行的末尾添加一个,这使得 Henri 的答案的该部分看起来像这样:
\starttypescript [serif] [timesnewromanps]
\setups[font:fallback:serif]
\definefontsynonym [Serif] [name:timesnewromanpsmt] [features=timesnewromanps-preset]
\definefontsynonym [SerifBold] [name:timesnewromanpsboldmt] [features=timesnewromanps-preset]
\definefontsynonym [SerifBoldItalic] [name:timesnewromanpsbolditalicmt] [features=timesnewromanps-preset]
\definefontsynonym [SerifItalic] [name:timesnewromanpsitalicmt] [features=timesnewromanps-preset]
\definefontsynonym [SerifCaps] [name:timesnewromanpsmtregular] [features=timesnewromanps-preset]
\stoptypescript