我是 XeLaTeX 的新手,我想用 ArnoPro 字体排版,当我使用字体大小 10pt 时,xeLaTeX 会自动加载字体 ArnoPro-smText 而不是 ArnoPro-Regular。
粗体和斜体字体也存在同样的问题,当我使用字体大小 11 时,ArnoPro-Regular 字体正在加载,但我需要以 10pt 排版。如何在 Xelatex 中加载 ArnoPro-Regular、ArnoPro-Bold 字体?
\documentclass{book}
\usepackage{fontspec}
\setmainfont[ItalicFont={Arno Pro Italic},
BoldFont={Arno Pro Bold},
BoldItalicFont={Arno Pro Bold Italic}
]{Arno Pro}
\begin{document}
Sample text \textit{itshape} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} | \textbf{Bold} | \textbf{\textit{Bold Italic}}
\end{document}
答案1
在 2018 年第四季度,也就是该季度三年后,您可能不再陌生xelatex
,并且可能早已找到合适的解决方案。其他面临相同(类型)问题的人可能会从这些细节中受益。
由于问题的焦点和可靠的解决方案,按照 Ulrike Fischer 早期和经常教授的概念,例如,在此字体问题xelatex
,其中包括字体名称,根据 Q ,值得花时间在特定的上下文中解决这个问题。
以下代码演示了字体大小和字体名称/样式,以确认 MWE 中标识的通用字体名称\setmainfont
实际上是xelatex
所有三种标准书籍类字体大小(10pt、11pt(10.95pt)和 12pt)使用的特定字体。考虑到可能的 Arno-Pro 字体数量,有必要排除其他可能性。(当然,最可靠的方法是只安装所选的字体。因此,这里 Q 的隐含上下文是从这些多个选项中进行正确的选择。)
MWE 定义了{Arno Pro}
,期望ArnoPro-Regular.otf
系统将使用 ,但 OP 的系统使用的是ArnoPro-SmText.otf
。在此系统(MacTeX,TexLive 2016)上,在命令中xelatex
看到,并使用所有三个标准书籍类正常字体大小。要具体了解这一点,请滚动到下面代码的 xelatex 生成的 .pdf 的末尾,以查看基于 的“示例文本”输出与输出相同。是在字体系列上构建的。“示例文本”与基于 构建的输出不匹配{Arno Pro}
\setmainfont
ArnoPro-Regular.otf
{Arno Pro}
\ArnoProThrZro
ArnoProThrZro
ArnoPro-Regular.otf
ArnoProThrOne
ArnoPro-SmText.otf
。看示例输出段如下代码。
真希望它如此简单。字体选择,即使是xelatex
,也需要注意一些细节,包括如何xelatex
做出决定。关于如何这系统(现在)设置完毕后,OSFONTDIR
路径设置在该系统的文件中被注释掉.bash_profile
(在某些系统中,是文件 .profile
,这似乎取决于用户拥有或习惯使用的 shell)。虽然xelatex
旨在通过使用 OSFONTDIR 路径访问系统的字体文件(当然还有“系统字体”字体文件),并通过字体名称的简单性使用它们,但xelatex
也(仍然)坚持“一个且只有一个字体定义”的概念。因此,当xelatex
查看所有OSFONTDIR
路径并找到字体定义和字体套件,或者例如定义.ttf
和.otf
定义时,xelatex
可能会难以通过通用名称识别字体。为了完全消除这种可能性(谁有时间不断追逐这些字体问题?),OSFONTDIR
根本不使用,并且字体手动安装到 texlive 树结构中,.ttf
文件进入其目录(文件夹)集,例如/fonts/truetype/<various font files>
,.otf
文件进入其目录(文件夹)集,例如/fonts/opentype/<various font files>
。在 texlive 树中设置这些目录可能需要几分钟,而这几分钟可以节省很多时间(和小时,等)。[当向 texlive 树结构添加新字体时,请记住 (A) (sudo) -H mktexlsr [(sudo) -H texhash] 和 (B) (sudo) fc-cache -fv。] 此外,在 .tex 文件中,使用实际字体文件名及其扩展名(现在)是“此处”的编码实践,其中xelatex
是预期的编译引擎。
不应该为 这样做xelatex
。 的“便利”和进步之一xelatex
是“按原样”使用已安装的字体。而且,正如这个例子所示,这种级别的字体规范在这个系统上不是必需的。“这里”,xelatex
确切地知道 指的是哪种字体{Arno Pro}
。然而,这是由于字体的“一个定义”,因为只有一个定义(部分原因是唯一的地方xelatex
是树结构,这大大增加了只有“一个定义”的可能性)。
底线是,以下内容表明,当所需字体以能够通过 唯一找到的方式安装时xelatex
,MWE 应该能够正常工作,以实现使用ArnoPro-Regular
而不是 的既定目的ArnoPro-SmText
。
\documentclass{book}
\usepackage{fontspec}
\usepackage{parskip}
\usepackage{setspace}
%https://www.wfonts.com/font/arno-pro
\setmainfont[ItalicFont={Arno Pro Italic},
BoldFont={Arno Pro Bold},
BoldItalicFont={Arno Pro Bold Italic}
]{Arno Pro}
%borrowing from here: https://tex.stackexchange.com/a/24600/170846
\makeatletter
\newcommand\thefontsize[1]{{#1 The current font size is: \f@size pt\par}}
\makeatother
%borrowing from here: https://tex.stackexchange.com/a/87908/170846
\newenvironment{localsize}[1]
{%
% \clearpage
\par
\let\orignewcommand\newcommand
\let\newcommand\renewcommand
\makeatletter
\input{bk#1.clo}% possible values for book.cls: 10, 11, 12
\makeatother
\let\newcommand\orignewcommand
}
{%
%\clearpage
\par
}
% borrowing from here: https://tex.stackexchange.com/a/255384/170846
% and from here: https://tex.stackexchange.com/a/37251/170846
\newfontfamily\ArnoProZroOne{ArnoPro-Regular.otf}
\newfontfamily\ArnoProZroTwo{ArnoPro-SmText.otf}
\newfontfamily\ArnoProZroThr{ArnoPro-Italic.otf}
\newfontfamily\ArnoProZroFor{ArnoPro-ItalicSmText.otf}
\newfontfamily\ArnoProZroFiv{ArnoPro-Bold.otf}
\newfontfamily\ArnoProZroSix{ArnoPro-BoldItalic.otf}
\newfontfamily\ArnoProZroSvn{ArnoPro-Smbd.otf}
\newfontfamily\ArnoProZroAte{ArnoPro-SmbdSmText.otf}
\newfontfamily\ArnoProZroNin{ArnoPro-SmbdItalicSmText.otf}
\newfontfamily\ArnoProOneZro{ArnoPro-Caption.otf}
\newfontfamily\ArnoProOneOne{ArnoPro-ItalicCaption.otf}
\newfontfamily\ArnoProOneTwo{ArnoPro-BoldCaption.otf}
\newfontfamily\ArnoProOneThr{ArnoPro-SmbdItalicCaption.otf}
\newfontfamily\ArnoProOneFor{ArnoPro-Subhead.otf}
\newfontfamily\ArnoProOneFiv{ArnoPro-ItalicSubhead.otf}
\newfontfamily\ArnoProOneSix{ArnoPro-BoldSubhead.otf}
\newfontfamily\ArnoProOneSvn{ArnoPro-BoldItalicSubhead.otf}
\newfontfamily\ArnoProOneAte{ArnoPro-SmbdSubhead.otf}
\newfontfamily\ArnoProOneNin{ArnoPro-SmbdItalicSubhead.otf}
\newfontfamily\ArnoProTwoZro{ArnoPro-Display.otf}
\newfontfamily\ArnoProTwoOne{ArnoPro-ItalicDisplay.otf}
\newfontfamily\ArnoProTwoTwo{ArnoPro-LightDisplay.otf}
\newfontfamily\ArnoProTwoThr{ArnoPro-LightItalicDisplay.otf}
\newfontfamily\ArnoProThrZro[ItalicFont=ArnoPro-Italic.otf,
BoldFont=ArnoPro-Bold.otf,
BoldItalicFont=ArnoPro-BoldItalic.otf
]{ArnoPro-Regular.otf}
\newfontfamily\ArnoProThrOne[%
ItalicFont={ArnoPro-ItalicSmText.otf}
]{ArnoPro-SmText.otf}
\begin{document}
\doublespacing
% see https://tex.stackexchange.com/a/14376/170846
\thefontsize\normalsize
%borrowing from here: https://tex.stackexchange.com/a/307369/170846
\expandafter\string\the\font
\begin{localsize}{10}
\parindent 0in
\thefontsize\normalsize
Sample text at 10pt
\expandafter\string\the\font
\textit{itshape \expandafter\string\the\font}
\textsc{Small caps \expandafter\string\the\font}
\textsc{\textit{Small caps Italic \expandafter\string\the\font}}
\textbf{Bold \expandafter\string\the\font}
\textbf{\textit{Bold Italic \expandafter\string\the\font}}
\end{localsize}
\begin{localsize}{11}
\parindent 0in
\thefontsize\normalsize
Sample text at 11pt
\expandafter\string\the\font
\textit{itshape \expandafter\string\the\font}
\textsc{Small caps \expandafter\string\the\font}
\textsc{\textit{Small caps Italic \expandafter\string\the\font}}
\textbf{Bold \expandafter\string\the\font}
\textbf{\textit{Bold Italic \expandafter\string\the\font}}
\end{localsize}
\begin{localsize}{12}
\parindent 0in
\thefontsize\normalsize
Sample text at 12pt
\expandafter\string\the\font
\textit{itshape \expandafter\string\the\font}
\textsc{Small caps \expandafter\string\the\font}
\textsc{\textit{Small caps Italic \expandafter\string\the\font}}
\textbf{Bold \expandafter\string\the\font}
\textbf{\textit{Bold Italic \expandafter\string\the\font}}
\end{localsize}
\singlespacing
\begin{localsize}{10}
\parindent 0in
Font set at 10pt
\ArnoProZroOne{ArnoPro-Regular.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroTwo{ArnoPro-SmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroThr{ArnoPro-Italic.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroFor{ArnoPro-ItalicSmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroFiv{ArnoPro-Bold.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroSix{ArnoPro-BoldItalic.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroSvn{ArnoPro-Smbd.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroAte{ArnoPro-SmbdSmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroNin{ArnoPro-SmbdItalicSmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneZro{ArnoPro-Caption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneOne{ArnoPro-ItalicCaption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneTwo{ArnoPro-BoldCaption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneThr{ArnoPro-SmbdItalicCaption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneFor{ArnoPro-Subhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneFiv{ArnoPro-ItalicSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneSix{ArnoPro-BoldSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneSvn{ArnoPro-BoldItalicSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneAte{ArnoPro-SmbdSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneNin{ArnoPro-SmbdItalicSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoZro{ArnoPro-Display.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoOne{ ArnoPro-ItalicDisplay.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoTwo{ArnoPro-LightDisplay.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoThr{ArnoPro-LightItalicDisplay.otf:\\ The quick brown fox jumps over the lazy dog.}
\end{localsize}
\par
\begin{localsize}{11}
\parindent 0in
Font set at 11pt
\ArnoProZroOne{ArnoPro-Regular.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroTwo{ArnoPro-SmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroThr{ArnoPro-Italic.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroFor{ArnoPro-ItalicSmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroFiv{ArnoPro-Bold.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroSix{ArnoPro-BoldItalic.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroSvn{ArnoPro-Smbd.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroAte{ArnoPro-SmbdSmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroNin{ArnoPro-SmbdItalicSmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneZro{ArnoPro-Caption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneOne{ArnoPro-ItalicCaption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneTwo{ArnoPro-BoldCaption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneThr{ArnoPro-SmbdItalicCaption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneFor{ArnoPro-Subhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneFiv{ArnoPro-ItalicSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneSix{ArnoPro-BoldSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneSvn{ArnoPro-BoldItalicSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneAte{ArnoPro-SmbdSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneNin{ArnoPro-SmbdItalicSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoZro{ArnoPro-Display.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoOne{ ArnoPro-ItalicDisplay.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoTwo{ArnoPro-LightDisplay.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoThr{ArnoPro-LightItalicDisplay.otf:\\ The quick brown fox jumps over the lazy dog.}
\end{localsize}
\par
\begin{localsize}{12}
\parindent 0in
Font set at 12pt
\ArnoProZroOne{ArnoPro-Regular.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroTwo{ArnoPro-SmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroThr{ArnoPro-Italic.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroFor{ArnoPro-ItalicSmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroFiv{ArnoPro-Bold.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroSix{ArnoPro-BoldItalic.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroSvn{ArnoPro-Smbd.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroAte{ArnoPro-SmbdSmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProZroNin{ArnoPro-SmbdItalicSmText.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneZro{ArnoPro-Caption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneOne{ArnoPro-ItalicCaption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneTwo{ArnoPro-BoldCaption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneThr{ArnoPro-SmbdItalicCaption.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneFor{ArnoPro-Subhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneFiv{ArnoPro-ItalicSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneSix{ArnoPro-BoldSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneSvn{ArnoPro-BoldItalicSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneAte{ArnoPro-SmbdSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProOneNin{ArnoPro-SmbdItalicSubhead.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoZro{ArnoPro-Display.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoOne{ ArnoPro-ItalicDisplay.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoTwo{ArnoPro-LightDisplay.otf:\\ The quick brown fox jumps over the lazy dog.}
\ArnoProTwoThr{ArnoPro-LightItalicDisplay.otf:\\ The quick brown fox jumps over the lazy dog.}
\end{localsize}
\bigskip
\begin{localsize}{10}
\parindent 0in
Sample text in 10pt \textit{Italics} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} | \textbf{Bold} | \textbf{\textit{Bold Italic}}
\ArnoProThrZro{Sample text ThrZro \textit{Italics} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} | \textbf{Bold} | \textbf{\textit{Bold Italic}}
}
\ArnoProThrOne{Sample text ThrOne \textit{Italics} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} | \textbf{Bold} | \textbf{\textit{Bold Italic}}
}
\end{localsize}
\begin{localsize}{11}
\parindent 0in
Sample text in 11pt \textit{Italics} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} | \textbf{Bold} | \textbf{\textit{Bold Italic}}
\ArnoProThrZro{Sample text ThrZro \textit{Italics} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} | \textbf{Bold} | \textbf{\textit{Bold Italic}}
}
\ArnoProThrOne{Sample text ThrOne \textit{Italics} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} | \textbf{Bold} | \textbf{\textit{Bold Italic}}
}
\end{localsize}
\begin{localsize}{12}
\parindent 0in
Sample text in 12pt \textit{Italics} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} | \textbf{Bold} | \textbf{\textit{Bold Italic}}
\ArnoProThrZro{Sample text ThrZro \textit{Italics} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} | \textbf{Bold} | \textbf{\textit{Bold Italic}}
}
\ArnoProThrOne{Sample text ThrOne \textit{Italics} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} | \textbf{Bold} | \textbf{\textit{Bold Italic}}
}
\end{localsize}
\end{document}
答案2
定义UprightFont
:
\documentclass{book}
\usepackage{fontspec}
\setmainfont{ArnoPro}[
UprightFont = *-Regular,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont= *-BoldItalic
]
\begin{document}
Sample text \textit{itshape} | \textsc{Small caps} | \textsc{\textit{Small caps Italic}} |
\textbf{Bold} | \textbf{\textit{Bold Italic}}
\end{document}