
我正在準備一個文檔,該文檔有助於套件fontspec
定義 main- 和 sans-font。在該文件中,我想將該主要字體與 Computer Modern 進行比較,或者更準確地說,將其後繼的 Latin Modern 進行比較。
我確信,寫作
\newfontfamily\lmfont{Latin Modern Roman}
將啟用包含所有 70 多個字體檔案的完整系列。但這是不正確的。
例如,當我說
{\lmfont\scshape{}abcd} {\scshape{}abcd}
我明白了:
左側是拉丁現代字體,但沒有小型大寫字母 :-(,右側是文檔的預設(“mainfont”)字體,因為它應該是這樣的。
為了進行比較,我想展示這個系列中字體的絕佳選擇/組合,即羅馬字體、無襯線字體和單聲道字體,添加了形狀和麵孔,例如-italic、-italic-bold、-slanted、 -slanted-bold , - 粗體, - 小號。
不幸的是,我的解決方案僅加載LMRoman10-Regular
和LMSans10-Regular
字體,而不加載LMRomanCaps10-Regular
.這就是為什麼\lmfont\scshape
(或\lmfont\ttfamily
) 不起作用。
那麼,是否有可能定義它\newfamily
包含完整的拉丁現代字體?
任何能夠讓我有一個簡單的巨集來並排比較兩個字體系列的解決方案都可以。
這是一個 MWE:
\documentclass{scrbook}
\usepackage{fontspec}
\setmainfont{Times New Roman} % and other definitions
\newfontfamily\lmfont{Latin Modern Roman} % this is not complete!!
%% New command to compare.
%% #1 defines the family/shape/series
\newcommand{\compare}[1]{%
{#1%
ABCD \dots{} XYZ, abcd \dots{} xyz\\
\lmfont{}ABCD \dots{} XYZ, abcd \dots{} xyz\par
}
}
\begin{document}
\compare{\upshape}
\compare{\itshape}
\compare{\itshape\bfseries}
\compare{\scshape}
\end{document}
答案1
不,它不是那樣工作的,而且確實不能。
不存在字體命名約定,且各種字體的作用截然不同。有些字體有一項smcp
功能,有些則沒有,必須指定用於小型大寫字母的字體。
fontspec
Latin Modern Roman 的情況非常不同:大約有 70 個字體文件,為了完成所有必要的作業而分析它們超出了範圍。
但是,對於特定情況,.fd
文件是可用的,因此您可以使用它們。
\documentclass{article}
\usepackage{fontspec}
\setmainfont{EB Garamond}
\newfontfamily\lmodern{Latin Modern Roman}[
NFSSFamily=lmr
]
\begin{document}
Abc\textsc{Abc}
\lmodern
Abc\textsc{Abc}
\end{document}
答案2
作為egreg優秀答案的附錄:對於將小型大寫字母儲存在單獨檔案中的自訂字體,例如名為SomeFont-RegularSC.otf
和SomeFont-BoldSC.otf
,您可以使用以下命令加載它們
\newfontfamily\somefont{SomeFont}[
UprightFont = *-Regular ,
SmallCapsFont = *-RegularSC ,
BoldFont = *-Bold ,
BoldFeatures = { SmallCapsFont = *-BoldSC },
% Etc.
Extension = .otf ]
您也可以將此命令放在一個名為的檔案中,SomeFont.fontspec
以便您可以\newfontfamily\somefont{SomeFont}
在文件中寫入。這可以避免在所有文件中留下對某一特定字體版本的依賴。