我在使用利用光学尺寸的字体时遇到了麻烦Adobe 字体(原名 Typekit) 在 LuaLaTeX 中。
1 · Adobe 字体
由于 Adobe Fonts 使用巧妙的注入机制将其字体文件注入字体菜单(但不注入相应的系统字体目录),并且由于 LuaLaTeX 使用自己的渲染器(与 XeLaTeX 的系统字体渲染不同),因此它无法识别 Adobe Fonts 字体。这促使我创建脚本将所有 Adobe Fonts 字体文件复制到一个目录中,以便于使用 fontspec:
\documentclass{article}
\usepackage{blindtext}
\usepackage{fontspec}
\defaultfontfeatures{Path={/Users/you/.local/share/polytextum/fonts/}}
\setmainfont[
UprightFont=*-Regular,
ItalicFont=*-Italic,
BoldFont=*-Smbd,
BoldItalicFont=*-SmbdItalic,
]{ArnoPro}
\begin{document}
\blinddocument
\end{document}
编译起来很好。
2 · LuaLaTeX 中的光学尺寸
这是光学尺寸代码 I 的 MWE想法可以在 LuaLaTeX 中工作:
\documentclass{article}
\usepackage{blindtext}
\usepackage{fontspec}
\defaultfontfeatures{Path={/Users/you/.local/share/polytextum/fonts/}}
\setmainfont[
UprightFeatures={
SizeFeatures={
{Size={-8.4}, Font=ArnoPro-Caption},
{Size={8.5-10.9}, Font=ArnoPro-SmText},
{Size={11-13.9}, Font=ArnoPro-Regular},
{Size={14-21.4}, Font=ArnoPro-Subhead},
{Size={21.5-}, Font=ArnoPro-Display}
},
},
ItalicFeatures={
SizeFeatures={
{Size={-8.4}, Font=ArnoPro-ItalicCaption},
{Size={8.5-10.9}, Font=ArnoPro-ItalicSmText},
{Size={11-13.9}, Font=ArnoPro-Italic},
{Size={14-21.4}, Font=ArnoPro-ItalicSubhead},
{Size={21.5-}, Font=ArnoPro-ItalicDisplay}
},
},
BoldFeatures={
SizeFeatures={
{Size={-8.4}, Font=ArnoPro-SmbdCaption},
{Size={8.5-10.9}, Font=ArnoPro-SmbdSmText},
{Size={11-13.9}, Font=ArnoPro-Smbd},
{Size={14-21.4}, Font=ArnoPro-SmbdSubhead},
{Size={21.5-}, Font=ArnoPro-SmbdDisplay}
},
},
BoldItalicFeatures={
SizeFeatures={
{Size={-8.4}, Font=ArnoPro-SmbdItalicCaption},
{Size={8.5-10.9}, Font=ArnoPro-SmbdItalicSmText},
{Size={11-13.9}, Font=ArnoPro-SmbdItalic},
{Size={14-21.4}, Font=ArnoPro-SmbdItalicSubhead},
{Size={21.5-}, Font=ArnoPro-SmbdItalicDisplay}
},
}
]{ArnoPro}
\begin{document}
\blinddocument
\end{document}
然而,这一切都给了我这个错误:
luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: "File not found: /Users/aramis/.local/share/polytextum/fonts/ArnoPro.".
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "ArnoPro" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.45
?
然后我想是因为没有ArnoPro.otf
,只有。所以我把这ArnoPro-Regular.otf
行改成了,但这也不起作用:]{ArnoPro}
]{ArnoPro-Regular}
luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: "File not found: /Users/aramis/.local/share/polytextum/fonts/ArnoPro-Regular.".
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "--" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.45
?
这很奇怪,因为:
- 那里是
ArnoPro-Regular.otf
一个文件/Users/you/.local/share/polytextum/fonts/
- 从哪來的
--
?
然后我继续将ArnoPro-Regular.otf
其重命名为ArnoPro.otf
(并进行了所有必要的更改),但问题仍然存在。仅当我复制ArnoPro.otf
并调用它后它才消失--.otf
。 但为什么?
我非常不想做这种“黑客行为”,而且对于它首先发生的事实我感到很困惑。
有没有办法我可以使用 Adobe Fonts 中的字体、使用 LuaLaTeX 和 Optical Sizes没有不得不诉诸‘黑客’?
答案1
没关系!在@SapharKoshet 的帮助下这个答案我已经设法弄清楚了问题出在哪里:LaTeX 不喜欢重复的字体,因此最好先定义默认的斜体字体ItalicFont=*-Italic
,然后在其中SizeFeatures
将常规字体的定义留空,如下所示:
ItalicFeatures={
SizeFeatures={
{Size={-8.4}, Font=ArnoPro-ItalicCaption},
{Size={8.5-10.9}, Font=ArnoPro-ItalicSmText},
% Before
% {Size={11-13.9}, Font=ArnoPro-Italic},
% After
{Size={11-13.9}},
{Size={14-21.4}, Font=ArnoPro-ItalicSubhead},
{Size={21.5-}, Font=ArnoPro-ItalicDisplay}
},
},
最后,最终的 MWE 如下所示(我还添加了,Extension=.otf
因为这意味着 LaTeX 不必搜索例如,ArnoPro-Regular.ttf
因为所有文件都是.otf
):
\documentclass{article}
\usepackage{blindtext}
\usepackage{fontspec}
\defaultfontfeatures{
Path={/Users/you/.local/share/polytextum/fonts/},
Extension={.otf},
}
\setmainfont[
UprightFont=*-Regular,
UprightFeatures={
SizeFeatures={
{Size={-8.4}, Font=*-Caption},
{Size={8.5-10.9}, Font=*-SmText},
{Size={11-13.9}},
{Size={14-21.4}, Font=*-Subhead},
{Size={21.5-}, Font=*-Display}
},
},
ItalicFont=*-Italic,
ItalicFeatures={
SizeFeatures={
{Size={-8.4}, Font=*-ItalicCaption},
{Size={8.5-10.9}, Font=*-ItalicSmText},
{Size={11-13.9}},
{Size={14-21.4}, Font=*-ItalicSubhead},
{Size={21.5-}, Font=*-ItalicDisplay}
},
},
BoldFont=*-Smbd,
BoldFeatures={
SizeFeatures={
{Size={-8.4}, Font=*-SmbdCaption},
{Size={8.5-10.9}, Font=*-SmbdSmText},
{Size={11-13.9}},
{Size={14-21.4}, Font=*-SmbdSubhead},
{Size={21.5-}, Font=*-SmbdDisplay}
},
},
BoldItalicFont=*-SmbdItalic,
BoldItalicFeatures={
SizeFeatures={
{Size={-8.4}, Font=*-SmbdItalicCaption},
{Size={8.5-10.9}, Font=*-SmbdItalicSmText},
{Size={11-13.9}},
{Size={14-21.4}, Font=*-SmbdItalicSubhead},
{Size={21.5-}, Font=*-SmbdItalicDisplay}
},
},
]{ArnoPro}
\begin{document}
\blinddocument
\end{document}