使用最近的字体规范将标点符号大小与小型大写字母匹配

使用最近的字体规范将标点符号大小与小型大写字母匹配

我重新参与了以下讨论: 将标点符号大小与小型大写字母匹配 James Ashton 提出的有趣解决方案“使撇号成为一个活动字符,并将其定义为仅在小型大写字母有效时使用 \raisebox”不再适用于较新版本的 fontspec,因为此选项具有全局作用(如以下讨论所述:新版本的 fontspec 给出 WordSpace 错误)。我发布了一个(几乎)MWE,但它不起作用;目的是创建一个“临时”小写字体。我无法更改代码来调整它。有人有解决方案吗?谢谢

\documentclass[a4paper,12pt]{report}
\usepackage{fontspec}
\defaultfontfeatures{Contextuals=NoAlternate}
\setmainfont[Ligatures=TeX,Scale=1.1]{EB Garamond}
\usepackage{polyglossia}
\setmainlanguage[babelshorthands=true]{italian}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newfontfamily{\spacedcaps}{EB Garamond}[%
\makeatletter
\let\horn@scshape\scshape
\def\scshape{\addfontfeature{Letters=UppercaseSmallCaps,Letters=SmallCaps,LetterSpace=2,WordSpace=1.2}%
\let\horn@apos\horn@@apos}
\def\horn@apos{'}
\def\horn@@apos{\raisebox{-0.4ex}{\kern0.06em'}}
% make ' (apostophe) active for the argument to chapter so we can lower it for small caps
\let\horn@chapter\chapter
\def\chapter{
\begingroup
    \catcode`\'=\active\begingroup\lccode`\~=`\'\lowercase{\endgroup\def~{\protect\horn@apos}}
    \horn@@chapter
}
\def\horn@@chapter#1{%
\horn@chapter{#1}
\endgroup
}
\makeatother
]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\@ifdefinable\@chap@title@rule@gap{\newdimen\@chap@title@rule@gap}
\renewcommand{\@makechapterhead}[1]{%
    \vspace*{50\p@}%
    \begingroup
    \setlength\parindent{\z@}%
    \setlength\parskip{\z@skip}%
    \raggedright \normalfont \large \scshape
    \hrule
    \setlength\prevdepth{\z@}%
    \setlength\@chap@title@rule@gap{.1\baselineskip}
    \nobreak \vspace{\@chap@title@rule@gap}%
    \interlinepenalty\@M
    \noindent\MakeLowercase #1\par
    \addtolength\@chap@title@rule@gap{.5\baselineskip}
    \addtolength\@chap@title@rule@gap{-\prevdepth}%
    \nobreak \vspace{\@chap@title@rule@gap}%
    \hrule
    \nobreak \vskip 40\p@
    \endgroup
    \setlength\prevdepth{\z@}%
}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{hyperref}
\hypersetup{unicode=true,hidelinks}

\begin{document}
\tableofcontents

\chapter{quel ramo dell'ago di como}
QUEL RAMO DELL'AGO DI COMO

\textsc{quel ramo dell'ago di como}

\end{document}

答案1

这不适用于\scshape,但我不认为您需要它。

\documentclass[a4paper,12pt]{report}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{xparse,l3regex}

\setmainfont{EB Garamond}[
  Scale=1.1,
  Contextuals=NoAlternate,
]
\newfontfamily{\spacedcaps}{EB Garamond}[
  Scale=1.1,
  Letters={UppercaseSmallCaps,SmallCaps},
  LetterSpace=2,
  WordSpace=1.2,
]

\setmainlanguage[babelshorthands=true]{italian}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ExplSyntaxOn
\RenewDocumentCommand{\textsc}{m}
 {
  \tl_set:Nn \l_tmpa_tl { #1 }
  \regex_replace_all:nnN { ['’] } { \c{loweredapostrophe} } \l_tmpa_tl
  {\spacedcaps \tl_use:N \l_tmpa_tl}
 }
\ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter
\newcommand{\loweredapostrophe}{\raisebox{-0.4ex}{\kern0.06em’}}
\newdimen\@chap@title@rule@gap
\renewcommand{\@makechapterhead}[1]{%
    \vspace*{50\p@}%
    \begingroup
    \setlength\parindent{\z@}%
    \setlength\parskip{\z@skip}%
    \raggedright \normalfont \large \scshape
    \hrule
    \setlength\prevdepth{\z@}%
    \setlength\@chap@title@rule@gap{.1\baselineskip}
    \nobreak \vspace{\@chap@title@rule@gap}%
    \interlinepenalty\@M
    \noindent\textsc{#1}\par
    \addtolength\@chap@title@rule@gap{.5\baselineskip}
    \addtolength\@chap@title@rule@gap{-\prevdepth}%
    \nobreak \vspace{\@chap@title@rule@gap}%
    \hrule
    \nobreak \vskip 40\p@
    \endgroup
    \setlength\prevdepth{\z@}%
}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{hyperref}
\hypersetup{unicode=true,hidelinks}

\begin{document}
\tableofcontents

\chapter{quel ramo dell'ago di como}
QUEL RAMO DELL'AGO DI C’OMO

\textsc{quel ramo dell'ago di c’omo}

\end{document}

注意,和都'可以使用,并且会降低。处理其他引号也很容易。

在此处输入图片描述

相关内容