[Tex/LaTex] How to suppress a “Rare” ligature that pre-empts a “Common” ligature for the same character pair

fontspecligaturesluatexopentype

In several documents I'm creating with LuaLaTeX (using MacTeX2012 on a Mac that's running MacOS X 10.7.5), I primarily use the Adobe-issued font Garamond Premier Pro as the main text font. I use this font because it provides a slew of

  • "Common" ligatures: These comprise not only the five TeX-standard f-ligatures, viz., ff, fi, fl, ffi, and ffl, but also ligatures for ft, fft, fb, ffb, and a few more; and

  • "Rare" (aka "Discretionary") ligatures: For this particular font, "rare" ligatures are available for the character pairs ct, st, sp, and ft (but not fft; see also below) in both upright and italic shapes, as well as for the character pairs as, is, us, at, et, th and a few more in the italic font shape only.

If just the "Common" ligature set is enabled (via the option Ligatures=Common), the ft and fft groups, in both upright and italic shapes, are typeset like this:

enter image description here

Just in case this matters, the Unicode character representations for these ligatures are U+E18D and U+E187, respectively. In the upright font shape, the "glyph id" numbers are 277 and 271 and the "character codes" are 57742 and 57735, respectively. In the italic font shape, the Unicode character representations are the same, but the "glyph id" and "character code" numbers are 283 and 276, and 57864 and 57857, respectively.

However, if the "Rare" ligature set is enabled — irrespective of whether the "Common" ligature set is enabled as well — the ft and fft character groups are rendered as follows:

enter image description here

(Aside: For another rendering of the "rare"-style ft-ligature, check out the web page Garamond type ft-ligature.)

Not only does the "Rare"-style ft ligature look rather different from its "Common"-style counterpart, the fft ligature no longer exists at all: the fft character triple is now rendered as a plain "f" followed by the "Rare"-style ft ligature. For my purposes, the absence of a ligature for the fft character triple if "Rare" ligatures are enabled is rather unfortunate. The fact that the crossbars of the "f" and "ft" glyphs don't line up properly in the italic font shape is also rather problematic. Separately, I also prefer the look of the "Common"-style ft-ligature to that of its "Rare"-style counterpart, but that's only a secondary concern. (Incidentally, the Unicode character representation for the "Rare" ft-ligature is U+E18E. In the upright font shape, its "glyph id" and "character number" codes are 278 and 57742, resp.; in the italic font shape the latter two numbers are 283 and 57864, resp.)

My question is: Is there a way — preferably using macros provided by the fontspec package — to disable the "Rare"-style ft ligature globally in order to re-enable the "Common"-style ft ligature — while still being able to use all other "Rare" ligatures as well as the "Common" ligatures?

Just for completeness, here's the code that generates the first example above:

% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=Common,
    ItalicFont={Garamond Premier Pro Italic}]
    {Garamond Premier Pro}
\begin{document}
ft fft \em ft fft
\end{document}

To generate the second example, replace the option Ligatures=Common with Ligatures={Common,Rare}.

Best Answer

Some thing like this using feature files should work:

First the feature file:

# scripts and languages, if the font use others they should be defined here too
languagesystem DFLT dflt;
languagesystem latn dflt;

# this undoes the effect of rare ligature on ft
feature liga {
  sub f_t.alt by f t;
} liga;

# move rare ft to historic ligatures
feature hlig {
  sub f t by f_t.alt;
} hlig;

# apply the regular ligature on ft and fft
feature liga {
  sub f f t by f_f_t;
  sub f t by f_t;
} liga;

The order of the above is important, this way regular “ft” and “fft” are used even with Rare ligatures, but not with Historic.

The glyph names should match those in the font with f_t.alt being the name of the unwanted “ft” ligature, and f_t & f_f_t being the names of the wanted ones.

The full feature file syntax is documented by Adobe (but LuaTeX supports v1.6 f the syntax + FontForge extension, not the current one, so there are some differences).

Then it can be applied to the font by using FeatureFile fontspec option:

\documentclass{article}
\usepackage{fontspec}

\begin{document}
\fontspec[Ligatures={Common,Rare},FeatureFile=test.fea]{Garamond Premier Pro}
ft fft \em ft fft

\fontspec[Ligatures={Common,Rare,Historic},FeatureFile=test.fea]{Garamond Premier Pro}
ft fft \em ft fft
\end{document}
Related Question