![使用具有多個 defaultfontfeatures 聲明的 .fontspec 文件](https://rvso.com/image/399810/%E4%BD%BF%E7%94%A8%E5%85%B7%E6%9C%89%E5%A4%9A%E5%80%8B%20defaultfontfeatures%20%E8%81%B2%E6%98%8E%E7%9A%84%20.fontspec%20%E6%96%87%E4%BB%B6.png)
我正在嘗試為 Minion3 建立 fontspec 定義文件,其中包括所有光學尺寸。當我在一個defaultfontfeatures
定義中定義所有事物時,它就可以工作:
\defaultfontfeatures[Minion3]
{
UprightFont = Minion3-Regular,
BoldFont = Minion3-Bold,
ItalicFont = Minion3-Italic,
BoldItalicFont = Minion3-BoldItalic,
%Numbers = {Proportional,OldStyle},
Numbers = {Proportional},
SizeFeatures = {
{ Size = -9.9, Font = Minion 3 Caption },
{ Size = 9.9-13.9 },
{ Size = 13.9-25.9, Font = Minion 3 Subhead},
{ Size = 25.9-, Font = Minion 3 Display},
},
BoldFeatures = {
SizeFeatures = {
{ Size = -9.9, Font = Minion 3 Caption Bold},
{ Size = 9.9-13.9 },
{ Size = 13.9-25.9, Font = Minion 3 Subhead Bold},
{ Size = 25.9-, Font = Minion 3 Display Bold},
},
},
ItalicFeatures = {
SizeFeatures = {
{ Size = -9.9, Font = Minion 3 Caption Italic},
{ Size = 9.9-13.9 },
{ Size = 13.9-25.9, Font = Minion 3 Subhead Italic},
{ Size = 25.9-, Font = Minion 3 Display Italic},
},
},
BoldItalicFeatures = {
SizeFeatures = {
{ Size = -9.9, Font = Minion 3 Caption Bold Italic},
{ Size = 9.9-13.9 },
{ Size = 13.9-25.9, Font = Minion 3 Subhead Bold Italic},
{ Size = 25.9-, Font = Minion 3 Display Bold Italic},
},
},
}
然而,根據 fontspec 手冊(第 12--13 頁),我應該能夠在同一個文件中為每個 Regular、Bold、Italic 和 BoldItalic 字體聲明,如下所示:
\defaultfontfeatures[Minion3]{
UprightFont = {Minion3R},
BoldFont = {Minion3B},
ItalicFont = {Minion3I},
BoldItalicFont = {Minion3BI},
%Numbers = {Proportional,OldStyle},
Numbers = {Proportional},
}
\defaultfontfeatures[Minion3R]{
Extension = .otf,
Font = Minion3-Regular,
SizeFeatures = {
{ Size = -9.9, Font = Minion3Caption-Regular },
{ Size = 9.9-13.9 },
{ Size = 13.9-25.9, Font = Minion3Subhead-Regular},
{ Size = 25.9-, Font = Minion3Display-Regular},
},
}
\defaultfontfeatures[Minion3B]{
Font = Minion3-Bold,
SizeFeatures = {
{ Size = -9.9, Font = Minion3Caption-Bold },
{ Size = 9.9-13.9 },
{ Size = 13.9-25.9, Font = Minion3Subhead-Bold},
{ Size = 25.9-, Font = Minion3Display-Bold},
},
}
\defaultfontfeatures[Minion3I]{
Font = Minion3-Italic,
SizeFeatures = {
{ Size = -9.9, Font = Minion3Caption-Italic },
{ Size = 9.9-13.9 },
{ Size = 13.9-25.9, Font = Minion3Subhead-Italic},
{ Size = 25.9-, Font = Minion3Display-Italic},
},
}
\defaultfontfeatures[Minion3BI]{
Font = Minion3-BoldItalic,
SizeFeatures = {
{ Size = -9.9, Font = Minion3Caption-BoldItalic },
{ Size = 9.9-13.9 },
{ Size = 13.9-25.9, Font = Minion3Subhead-BoldItalic},
{ Size = 25.9-, Font = Minion3Display-BoldItalic},
},
}
不幸的是,第二個版本不起作用,編譯失敗並出現錯誤
!軟體包 fontspec 錯誤:找不到字體「Minion3R」。
fontspec 定義檔稱為 Minion3.fontspec
演示功能的測試 tex 檔取自http://tex.stackexchange.com/q/126096/14066(https://bitbucket.org/phg/lua-la-tex-tests/src/default/latex/ltx-fontspec-optical-size-3.tex):
\documentclass [12pt] {article}
\usepackage {fontspec}
%% set your font here
%\setmainfont {Arno Pro}
\setmainfont{Minion3}
%% helper for extracting the font name name, please ignore
\def\fontinfo{%
\directlua {
local f = fonts.hashes.identifiers [font.current ()]
if f then
tex.sprint (f.fullname, " ", string.sub (tostring (f.size / 2^16), 1, 4), "pt")
end
}%
}
%% testing macro
\def\test#1{%
#1\section {\detokenize {#1}}
\begin {itemize}
\item {\rmfamily \upshape \fontinfo}
\item {\rmfamily \upshape \bfseries \fontinfo}
\item {\rmfamily \itshape \fontinfo}
\item {\rmfamily \itshape \bfseries \fontinfo}
\item {\rmfamily \scshape \fontinfo}
\end {itemize}
}
\begin {document}
testing family ``\rmdefault'' ...\par\vskip1cm
\test\tiny
\test\scriptsize
\test\small
\test\normalsize
\test\large
\test\Large
\test\LARGE
\test\Huge
\end {document}
我確信我錯過了一些明顯的東西,但無法弄清楚是什麼。
編輯:
由於這不是Minion3
問題並且該字體是專有的,因此可能很難複製。目前,這個問題在沒有 的情況下也可以重現SizeFeatures
,因此我添加了一個新MyXCharter.fontspec
文件,該文件使用 texlive 附帶的字體集重現了第一個障礙:
\defaultfontfeatures[MyXCharter]{
UprightFont = {XCharterR},
BoldFont = {XCharterB},
ItalicFont = {XCharterI},
BoldItalicFont = {XCharterBI},
SlantedFont = {XCharterS},
BoldSlantedFont = {XCharterBS},
%Numbers = {Proportional,OldStyle},
Numbers = {Proportional},
}
\defaultfontfeatures[XCharterR]{
Extension = .otf,
Font = XCharter-Roman,
}
\defaultfontfeatures[XCharterB]{
Extension = .otf,
Font = XCharter-Bold,
}
\defaultfontfeatures[XCharterI]{
Extension = .otf,
Font = XCharter-Italic,
}
\defaultfontfeatures[XCharterBI]{
Extension = .otf,
Font = XCharter-BoldItalic,
}
\defaultfontfeatures[XCharterS]{
Extension = .otf,
Font = XCharter-Slanted,
}
\defaultfontfeatures[XCharterBS]{
Extension = .otf,
Font = XCharter-BoldSlanted,
}