# Matching punctuation size to small caps with recent fontspec

I reconnect myself to this discussion: Matching punctuation size to small caps The interesting solution posted by James Ashton "to make the apostrophe an active character and define it to use \raisebox only when small caps are in effect" is no more working with the more recent versions of fontspec, for this options acts globally (as explains the following discussion: New version of fontspec gives WordSpace error). I post an (almost) MWE, that is not working; the aim is to create an "ad hoc" small caps font. I'm not able to change the code to adjust it. Has anyone a solution? Thanx

\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
\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}
\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
\nobreak \vspace{\@chap@title@rule@gap}%
\hrule
\nobreak \vskip 40\p@
\endgroup
\setlength\prevdepth{\z@}%
}
\makeatother

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

\usepackage{hyperref}

\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}


This won't work with \scshape, but I don't think you need it.

\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
\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
\nobreak \vspace{\@chap@title@rule@gap}%
\hrule
\nobreak \vskip 40\p@
\endgroup
\setlength\prevdepth{\z@}%
}
\makeatother

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

\usepackage{hyperref}

\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}


Note that both ' and ’` can be used and will be lowered. It would be easy to also cope with other quotation marks as well.

• It works in a parfetct way (obviously...). Thanx a lot! Mar 5 '17 at 17:36