我希望有一些代码来设置文档范围内的字母“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
和 之间的任何字距调整对。
您应该向字体开发人员索取一套风格集。