我从https://github.com/georgd/EB-Garamond/releases/tag/nightly并将所有字体、.otf 和 .ttf 复制到~/.fonts/e
该字体包含光学尺寸 08pt 和 12pt 的不同字体文件:
但是,如果我创建一个包含 EBGaramond12-Italic 的文档并使用 LuaLaTeX 对其进行编译,我的 PDF 阅读器只会显示以下字体:
%!TEX program = lualatex
\documentclass{article}
\usepackage{fontspec}
% https://tex.stackexchange.com/a/79783/38905
\setmainfont[%
SizeFeatures={%
{Size={-12},
Font=*08-Regular,
ItalicFont=*08-Italic},
{Size={12-},
Font=*12-Regular,
ItalicFont=*12-Italic}
},
]{EB Garamond}
\begin{document}
\normalsize
ABCDEFGHIJKLMNOPQRSTUVWXYZ
\huge
ABCDEFGHIJKLMNOPQRSTUVWXYZ
\normalsize
\textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\huge
\textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\end{document}
PDF 格式如下:
这是用
This is LuaHBTeX, Version 1.15.0 (TeX Live 2022/TeX Live for SUSE Linux)
Development id: 7509
为什么这不能按预期工作?我该如何解决这个问题?
答案1
手册fontspec
中提到了使用SizeFeatures
with ItalicFeatures
:
与其他功能的交互为了与、等和
SizeFeatures
一起工作,需要严格的层次结构:ItalicFeatures
BoldFeatures
SmallCapsFeatures
UprightFeatures = { SizeFeatures = { { Size = -10, Font = ..., % if necessary SmallCapsFeatures = {...}, ... % other features for this size range }, ... % other size ranges } }
虽然没有明确提到,但同样的原则也适用ItalicFont
:首先应用字体形状(如斜体或直立),然后再进行尺寸处理,因此在组合它们时需要遵循特定的顺序。
SizeFeatures
您可以通过将斜体字体移动到来实现ItalicFeatures
:
%!TEX program = lualatex
\documentclass{article}
\usepackage{fontspec}
\setmainfont[%
SizeFeatures={%
{Size={-12}, Font=*08-Regular},
{Size={12-}, Font=*12-Regular},
},
ItalicFeatures={%
SizeFeatures={%
{Size={-12}, Font=*08-Italic},
{Size={12-}, Font=*12-Italic},
},
},
]{EB Garamond}
\begin{document}
\normalsize
ABCDEFGHIJKLMNOPQRSTUVWXYZ
\huge
ABCDEFGHIJKLMNOPQRSTUVWXYZ
\normalsize
\textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\huge
\textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\end{document}
答案2
通过这种方式调用\setmainfont{...}
可以得到期望的结果:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{ebgaramond}[
UprightFeatures={
SizeFeatures={
{Size={12-},Font=ebgaramond12regular},
{Size={-12},Font=ebgaramond08regular}
}},
ItalicFeatures={
SizeFeatures={
{Size={12-},Font=ebgaramond12italic},
{Size={-12},Font=ebgaramond08italic}
}}]
\begin{document}
\normalsize
ABCDEFGHIJKLMNOPQRSTUVWXYZ
\huge
ABCDEFGHIJKLMNOPQRSTUVWXYZ
\normalsize
\textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\huge
\textit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\end{document}