我刚开始使用 LuaLaTeX。主要是因为我想ttf
在演示中使用字体。我的 MWE 看起来像
\documentclass{article}
\usepackage{fontspec}
\setmainfont[]{HelveticaNeue/HelveticaNeueLTCom-Th.ttf}
\begin{document}
Test
\end{document}
我在与 MWE 文件相同的文件夹中有一个名为的文件夹HelveticaNeue
。该文件夹包含著名字体的许多版本Helvetica Neue
。内容如下
HelveticaNeueLTCom-Bd.ttf
HelveticaNeueLTCom-BdCn.ttf
HelveticaNeueLTCom-BdCnO.ttf
HelveticaNeueLTCom-BdEx.ttf
HelveticaNeueLTCom-BdExO.ttf
HelveticaNeueLTCom-BdIt.ttf
HelveticaNeueLTCom-BdOu.ttf
HelveticaNeueLTCom-Blk.ttf
HelveticaNeueLTCom-BlkCn.ttf
HelveticaNeueLTCom-BlkCnO.ttf
HelveticaNeueLTCom-BlkEx.ttf
HelveticaNeueLTCom-BlkExO.ttf
HelveticaNeueLTCom-BlkIt.ttf
HelveticaNeueLTCom-Cn.ttf
HelveticaNeueLTCom-CnO.ttf
HelveticaNeueLTCom-Ex.ttf
HelveticaNeueLTCom-ExO.ttf
HelveticaNeueLTCom-Hv.ttf
HelveticaNeueLTCom-HvCn.ttf
HelveticaNeueLTCom-HvCnO.ttf
HelveticaNeueLTCom-HvEx.ttf
HelveticaNeueLTCom-HvExO.ttf
HelveticaNeueLTCom-HvIt.ttf
HelveticaNeueLTCom-It.ttf
HelveticaNeueLTCom-Lt.ttf
HelveticaNeueLTCom-LtCn.ttf
HelveticaNeueLTCom-LtCnO.ttf
HelveticaNeueLTCom-LtEx.ttf
HelveticaNeueLTCom-LtExO.ttf
HelveticaNeueLTCom-LtIt.ttf
HelveticaNeueLTCom-Md.ttf
HelveticaNeueLTCom-MdCn.ttf
HelveticaNeueLTCom-MdCnO.ttf
HelveticaNeueLTCom-MdEx.ttf
HelveticaNeueLTCom-MdExO.ttf
HelveticaNeueLTCom-MdIt.ttf
HelveticaNeueLTCom-Roman.ttf
HelveticaNeueLTCom-Th.ttf
HelveticaNeueLTCom-ThCn.ttf
HelveticaNeueLTCom-ThCnO.ttf
HelveticaNeueLTCom-ThEx.ttf
HelveticaNeueLTCom-ThExO.ttf
HelveticaNeueLTCom-ThIt.ttf
HelveticaNeueLTCom-UltLt.ttf
HelveticaNeueLTCom-UltLtCn.ttf
HelveticaNeueLTCom-UltLtCnO.ttf
HelveticaNeueLTCom-UltLtEx.ttf
HelveticaNeueLTCom-UltLtExO.ttf
HelveticaNeueLTCom-UltLtIt.ttf
HelveticaNeueLTCom-XBlkCn.ttf
HelveticaNeueLTCom-XBlkCnO.ttf
我使用 (Windows 7, LuaTeX 版本 0.76.0-2013062820, rev 4627) 编译该文件lualatex filename
。我收到一个错误;
我添加了一个屏幕截图,因为日志文件中不存在该错误。
另一个问题是如何使用不同的字体功能,如小写字母、斜体、粗体等。我发现您可以像这样定义它:
\setmainfont[
BoldFont = Fontname-Bold,
ItalicFont = Fontname-Italic,
BoldItalicFont = Fontname-BoldItalic
]{Fontname}
但我在字体文件中没有找到小写字母ttf
。
更新
根据 Herbert 的建议,我将所有ttf
字体文件添加到我的 Windows 字体文件夹中(现在我可以在 Word 等中使用它们)。如下所示
然后我相应地改变了 MWE:
\documentclass{article}
\usepackage{fontspec}
%\setmainfont[]{HelveticaNeue/HelveticaNeueLTCom-Th.ttf}
\setmainfont[]{Helvetica Neue LT Com 23}
\begin{document}
Test
\end{document}
并收到此错误消息:
按照 Mico 的建议(将ttf
文件放在与 MWE 文件相同的文件夹中)是可行的。我不明白为什么,我想知道如何使用粗体、小写字母等。我必须手动定义所有内容吗?
第二次更新
双击字体文件后,我看到了“真实”名称。此名称适用于系统字体;
\setmainfont[]{HelveticaNeueLT Com 35 Th}
答案1
将字体文件放入系统字体目录,然后使用
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Helvetica Neue}
\begin{document}
Test \textbf{Test} \textit{Test}
\end{document}
该文档包含以下字体:
voss@shania:~> pdffonts Test/test7.pdf
name type encoding emb sub uni object ID
--------------------------- ------------- ------------ --- --- --- ---------
NZAOYG+HelveticaNeue CID Type 0C Identity-H yes yes yes 4 0
WLHJWU+HelveticaNeue-Bold CID Type 0C Identity-H yes yes yes 5 0
PRPRRI+HelveticaNeue-Italic CID Type 0C Identity-H yes yes yes 6 0
也许您的 Helvetica 版本有其他名称,请在示例中进行更改。
以下是您的信息HelveticaNeueLTCom-Lt.ttf
:
voss@shania:~/Fonts/Helvetica/ttf> otfinfo -i HelveticaNeueLTCom-Lt.ttf
Family: HelveticaNeueLT Com 45 Lt
Subfamily: Regular
Full name: Helvetica Neue LT Com 45 Light
PostScript name: HelveticaNeueLTCom-Lt
Preferred family: Helvetica Neue LT Com
Preferred subfamily: 45 Light
Mac font menu name: HelveticaNeueLT Com 45 Lt
Version: Version 2.01;2006
Unique ID: Linotype GmbH:Helvetica Neue LT Com 45 Light:2006
Description: Helvetica is one of the most famous and popular typefaces in the world. It lends an air of lucid efficiency to any typog
以下是字体的设置:
\setmainfont[
BoldFont=HelveticaNeueLTCom-Md,
ItalicFont=HelveticaNeueLTCom-LtIt,
]{HelveticaNeueLTCom-Lt}
输出为:
对于小型大写字体使用:
SmallCapsFont=TeXGyre Heros,
SmallCapsFeatures={Letters=SmallCaps},
答案2
\setmainfont
据我所知,该包的命令fontspec
主要设计用于处理不超过四个成员的字体系列:常规、斜体、粗体和粗斜体;幸运的是,许多字体系列都是以这种方式设置的。然而,有些字体超系列有更多成员,通过以下方式区分重量-- 例如,Helvetica Neue 不仅有两种,而是九种 [!] 字重:超轻、细、轻、罗马、中、粗、重、黑色和特黑 --间距(“浓缩”和“扩展”亚科与“常规”亚科相伴),以及(当然)形状(直立和斜体/倾斜)。曾经有(现在仍然存在……)字体系列以“专家字体”文件为特色,用于小型大写字母和旧式数字等功能;对于以现代 OpenType 格式发布的字体,这些专家功能(如果有的话)现在通常包含在主字体文件中。)
面对这样的超家族,软件包提供的字体选择机制fontspec
将不堪重负。如果没有用户提供的明确指导,选择“正确”的中等和粗体字重的可能性一定很低。显然,从超家族成员中做出的选择比为基本书籍或文章选择字体要复杂得多。
使用该\newfontfamily
指令,您可能可以想出大约二十几种“常规大小”的字体系列,以满足您的大多数排版需求。
无衬线超级字体的经验法则(您应将其仅视为起点,而不是某种自然法则!)是“基本”和“粗体”粗细应相差 20 或 30 个“单位”,但不能相差 40 个单位或更多。[如果您不确定发生了什么,UltraLights 有时被称为 20s,thin 是 30s,lights 是 40,等等,黑色在 90s,特黑在 100s。]
第二条经验法则是,不要将压缩字符、常规字符和扩展字符混在一起。当然,根据您的排版需求,您可能也想尝试忽略这条经验法则!
使用这些经验规则作为起点,您可以尝试设置以下字体系列:
\newfontfamily\NHBasic[%%basic weight: 50, "bold" weight: 70
Extension = .ttf,
ItalicFont = HelveticaNeueLTCom-It,
BoldFont = HelveticaNeueLTCom-Bd,
BoldItalicFont = HelveticaNeueLTCom-BdIt]
{HelveticaNeueLTCom-Roman}
\newfontfamily\NHBasicCn[%%basic weight: 50, "bold" weight: 70
Extension = .ttf,
ItalicFont = HelveticaNeueLTCom-CnO,
BoldFont = HelveticaNeueLTCom-BdCn,
BoldItalicFont = HelveticaNeueLTCom-BdCnO]
{HelveticaNeueLTCom-Cn}
\newfontfamily\NHBasicEx[%%basic weight: 50, "bold" weight: 70
Extension = .ttf,
ItalicFont = HelveticaNeueLTCom-ExO,
BoldFont = HelveticaNeueLTCom-BdEx,
BoldItalicFont = HelveticaNeueLTCom-BdExO]
{HelveticaNeueLTCom-Ex}
\newfontfamily\NHUltra[%%basic weight: 20, "bold" weight: 40
Extension = .ttf,
ItalicFont = HelveticaNeueLTCom-UltLtIt,
BoldFont = HelveticaNeueLTCom-Lt,
BoldItalicFont = HelveticaNeueLTCom-LtIt]
{HelveticaNeueLTCom-UltLt}
\newfontfamily\NHUltraEx[%%basic weight: 20, "bold" weight: 40
Extension = .ttf,
ItalicFont = HelveticaNeueLTCom-UltLtExO,
BoldFont = HelveticaNeueLTCom-LtEx,
BoldItalicFont = HelveticaNeueLTCom-LtExO]
{HelveticaNeueLTCom-UltLtEx}
\newfontfamily\NHUltraCn[%%basic weight: 20, "bold" weight: 40
Extension = .ttf,
ItalicFont = HelveticaNeueLTCom-UltLtCnO,
BoldFont = HelveticaNeueLTCom-ThCn,
BoldItalicFont = HelveticaNeueLTCom-ThCnO]
{HelveticaNeueLTCom-UltLtCn}
\newfontfamily\NHThin[%%basic weight: 30, "bold" weight: 50
Extension = .ttf,
ItalicFont = HelveticaNeueLTCom-ThIt,
BoldFont = HelveticaNeueLTCom-Roman,
BoldItalicFont = HelveticaNeueLTCom-It]
{HelveticaNeueLTCom-Th}
\newfontfamily\NHThinEx[%%basic weight: 30, "bold" weight: 50
Extension = .ttf,
ItalicFont = HelveticaNeueLTCom-ThExO,
BoldFont = HelveticaNeueLTCom-Ex,
BoldItalicFont = HelveticaNeueLTCom-ExO]
{HelveticaNeueLTCom-ThEx}
\newfontfamily\NHThinCn[%%basic weight: 30, "bold" weight: 50
ItalicFont = HelveticaNeueLTCom-ThCnO,
BoldFont = HelveticaNeueLTCom-Cn,
BoldItalicFont = HelveticaNeueLTCom-CnO]
{HelveticaNeueLTCom-ThCn}
\newfontfamily\NHLight[%%basic weight: 40, "bold" weight: 60
ItalicFont = HelveticaNeueLTCom-LtIt,
BoldFont = HelveticaNeueLTCom-Md,
BoldItalicFont = HelveticaNeueLTCom-MdIt]
{HelveticaNeueLTCom-Lt}
\newfontfamily\NHLightEx[%%basic weight: 40, "bold" weight: 60
ItalicFont = HelveticaNeueLTCom-LtExO,
BoldFont = HelveticaNeueLTCom-MdEx,
BoldItalicFont = HelveticaNeueLTCom-MdExO]
{HelveticaNeueLTCom-LtEx}
\newfontfamily\NHLightCn[%%basic weight: 40, "bold" weight: 60
ItalicFont = HelveticaNeueLTCom-LtCnO,
BoldFont = HelveticaNeueLTCom-MdCn,
BoldItalicFont = HelveticaNeueLTCom-MdCnO]
{HelveticaNeueLTCom-LtCn}
要以“基本”字体开始某些内容,您可以发出命令\NHBasic
,要切换到超轻浓缩字体,您可以发出指令\NHUltraCn
,等等。