5

Using lualatex and fontspec with a special Garamond font.

The font I use has two versions of the apostrophe: a normal high and a low small caps one.

The problem occurs using small caps feature, because by default it loads the low apostrophe with small capitals, that, in some cases, is not correct. It creates some problems when it follows the capital letters of names, e.g. in many Italian surnames.

Here a pic, on the left there are the low apostrophes loaded using smallcaps (1, 3): 1 it's a wrong result but 3 is correct. 2 It's right and 4 is wrong. The problem is more serious when small caps are automatic (e.g. in packages like Biblatex philosophy-verbose, this is my real problem). But also using the solution D'O\textsc{nofrio} - when it is possible - it's not good at all because latex lost the kerning between O and \textsc{n}.

Is there a way for changing the type of apostrophe depending on the previous letter? Or is there any other way to solve the problem?

Thank you in advance

enter image description here

1
  • Imho some substitution should be possible, but without a real font it is difficult to test. Apr 16, 2019 at 22:18

2 Answers 2

2

I don't have the font to actually check this approach, so what I did as a surrogate is to print apostrophes in bold red those which should be output as \textup{'}, and those in black will be output as \scshape'.

I use listofitems to redefine \textsc. Here I search for all combinations of capital letters followed by an apostrope. While all the rest of the argument is output in \scshape, including apostrophes that follow lowercase letters, those apostrophe's following uppercase letters I output here as \textcolor{red}{\bfseries'}. This line should merely be replaced with \textup{'} to achieve the desired behavior sought by the OP.

\documentclass{article}
\usepackage{listofitems,xcolor}
\let\svtextsc\textsc
\renewcommand\textsc[1]{%
  \setsepchar{A'||B'||C'||D'||E'||F'||G'||H'||I'||J'||K'||L'||M'||%
    N'||O'||P'||Q'||R'||S'||T'||U'||V'||W'||X'||Y'||Z'}%
  \greadlist\scarg{#1}%
  \bgroup%
  \scshape%
  \foreachitem\z\in\scarg[]{%
    \z%
    \ifnum\zcnt<\listlen\scarg[]\relax
      \expandafter\expandafter\expandafter%
        \processapostrophe\scargsep[\zcnt]%
    \fi%
  }%
  \egroup%
}
\def\processapostrophe#1#2{#1%
  \textcolor{red}{\bfseries'}% replace this line with \textup{'}
}
\begin{document}
\textsc{D'Onofrio Dell'Omo}
\end{document}

enter image description here

2
  • Thanks a lot Steven. It works, but with a problem: in the output appears a space between the "fixed" apostrophe and the following letter. Like "D' Onofrio". I'm not good enough to solve it alone. :(
    – gattex
    Apr 17, 2019 at 5:25
  • @gattex When you replaced the line with \textup{'}, did you add a % sign to the end of the line? Without it, you will introduce a stray space character. Apr 17, 2019 at 9:47
3

You can substituate glyphs conditionally. The main problem is to find out the correct name. In EBGaramond I found e.g. a variant called sinf:

\documentclass[12pt]{article}
\usepackage{fontspec}

\directlua{
   fonts.handlers.otf.addfeature{
    name = "apo-sc",
    type = "chainsubstitution",
    lookups = {
      {
        type = "substitution",
        data = {
          ["’"] = "quotesingle.sinf", 
        },
      },
    },
    data = {
      rules = {
        {
          before  = { { "A", "B", "C", "D"} },
          current = { { "’" } },
          lookups = { 1 },
        },
      },
    },
  }
}

\setmainfont{EBGaramond}[SmallCapsFeatures={RawFeature=+apo-sc}]



\begin{document}
D'ono'frio A' B' C' 

\textsc{D'ono'frio A' B' C' E'}
\end{document}

enter image description here

1
  • Also this solution could be ok. Thank you very much.
    – gattex
    Apr 18, 2019 at 8:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .