
我想要一些程式碼來在文件範圍內設定字母“v”的特定字元變體(僅當它是單字中的第一個時)。 MWE中的解決方案不是解決方案,因為我有一個數百頁的文件。有什麼建議嗎?謝謝。
\documentclass[a4paper,14pt,openright,twoside]{memoir}
\usepackage[T1]{fontenc}
\usepackage[scale=1,osf,nf,lf]{ebgaramond}
\usepackage{fontspec}
\usepackage{microtype}
\usepackage{csquotes}
\usepackage{realscripts}
\begin{document}
Normal set:
{\fontshape{it}
\addfontfeature{RawFeature=+hlig}
\addfontfeature{CharacterVariant=5:2}
\addfontfeature{RawFeature=+liga}
\addfontfeature{RawFeature=+dlig}
\addfontfeature{RawFeature=+swsh}
\addfontfeature{Numbers=OldStyle}
\selectfont
Ha visto un valvassore vivere come un valvassino invidioso che gridava evviva!}
Nice to have:
{\fontshape{it}
\addfontfeature{RawFeature=+hlig}
\addfontfeature{CharacterVariant=5:1}
\addfontfeature{RawFeature=+liga}
\addfontfeature{RawFeature=+dlig}
\addfontfeature{RawFeature=+swsh}
\addfontfeature{Numbers=OldStyle}
\selectfont
Ha {\addfontfeature{CharacterVariant=5:2}v}isto un {\addfontfeature{CharacterVariant=5:2}v}alvassore {\addfontfeature{CharacterVariant=5:2}v}ivere come un {\addfontfeature{CharacterVariant=5:2}v}alvassino invidioso che gridava evviva!}
\end{document}
答案1
您可以使用字元類別:
\documentclass[a4paper,14pt,openright,twoside]{memoir}
\usepackage{fontspec}
\setmainfont{EB Garamond}[
Numbers=Lining,
ItalicFeatures={
RawFeature=+hlig,
RawFeature=+liga,
RawFeature=+dlig,
RawFeature=+swsh,
Numbers=OldStyle,
},
]
\newfontfamily\varv{EB Garamond}[
Numbers=Lining,
ItalicFeatures={
RawFeature=+hlig,
RawFeature=+liga,
RawFeature=+dlig,
RawFeature=+swsh,
Numbers=OldStyle,
CharacterVariant=5:2,
},
]
\XeTeXinterchartokenstate=1
\newXeTeXintercharclass\vclass
\XeTeXcharclass`v=\vclass
\XeTeXinterchartoks 255 \vclass = {\openswashv}
\makeatletter
\newcommand\openswashv{%
% by preceding the v with U+200C it's not at the boundary any more
\ifnum\strcmp{\f@shape}{it}=\z@
\begingroup\varv^^^^200cv\endgroup
\nobreak\hspace{0pt}% allow hyphenation in the rest of the word
\expandafter\@gobble
\fi
}
\makeatother
\begin{document}
Normal font:
Ha visto un valvassore vivere come un valvassino invidioso che gridava evviva!
Italic font: {\itshape
Ha visto un valvassore vivere come un valvassino invidioso che gridava evviva!
}
\end{document}
這允許對單字的其餘部分進行連字符(但對於與義大利語不同的語言可能會給出一些錯誤的連字符點)。我檢查過,EB Garamond 沒有定義v
與另一個字母之間的任何字距調整對。
您應該向字體開發人員詢問樣式集。