Contextual alternates and lettrine – LuaLaTeX

fontslettrineluaotfloadluatex

I'm using a font with "calt" (contextual alternates) on LuaLaTeX – as a matter of fact, BemboBookMT. So, for example, Q has a "tail" when followed by a u:

Q vs Quote

When I use lettrine, I get a standard Q even if Q is followed by a u: possibly because LaTeX doesn't "see" the chain due to lettrine implementation.

A possibility I see is to manually select the alternative glyph; with

\lettrine{\symbol{"E001}}{}uestion

I obtain a long-tail Q even in Lettrine Though, this is a bit tricky, and I wonder if there's a better way to deal with the issue. For example adjusting the font features through Lua. Perhaps there's a way to code the chain substitution, provided that you know how lettrine exactly works…

I thought also of setting the long tail Q as default (with a type = "substitution" feature), and then set a "chainsubstitution" feature only for the cases where I want the standard tail. But I didn't manage to make it work.

EDIT: Here an example of how the desired output could work:

enter image description here

Best Answer

As Daniel Flipo, author of lettrine, says, contextual alternates won’t work here. But I’ve never liked the way Monotype’s Bembo handles Q, so I turn calt off and do it myself. If your text almost always has room for the longest tail, you can make that the default but still choose the short or medium tail if needed, like this:

\documentclass[12pt]{article}
\usepackage{fontspec,lettrine}
\directlua{
  fonts.handlers.otf.addfeature{
    name = "bigq",
    type = "alternate",
    data = {
      Q = "Q.001",
    },
  }
  fonts.handlers.otf.addfeature{
    name = "medq",
    type = "alternate",
    data = {
      Q = "Q.002",
    },
  }
}
\setmainfont{Bembo Book MT Pro}[
  Contextuals=NoAlternate,
  RawFeature=+bigq]
\linespread{1.10345}% approx. 12/16, making room for the tails
\begin{document}
\lettrine{Q}{uaesitum} est de Deo, Angelo et homine. De Deo quaesitum
est et quantum ad divinam naturam et quantum ad naturam humanam
assumptam. Quantum ad divinam naturam quaesitum est: utrum beatus
Benedictus in visione qua vidit totum mundum, divinam essentiam
viderit.

{\addfontfeature{RawFeature={-bigq,+medq}}Qi Gong}

{\addfontfeature{RawFeature=-bigq}(NASDAQ.)}
\end{document}

output

Related Question