Having trouble enabling ligatures with HF&J's Mercury Text OpenType font

I'm sure this font supports ligatures, but I can't get them to show up.

Example with Roboto for comparison:

\documentclass[
11pt,
a4paper
]{scrartcl}

\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}

\begin{document}

\setmainfont[
ExternalLocation,
Extension=.ttf,
UprightFont=*-Regular,
ItalicFont=*-Italic,
BoldFont=*-Bold,
BoldItalicFont=*-BoldItalic,
Ligatures=Common
]{Roboto}

roboto fight flight has ligatures

\setmainfont[
ExternalLocation,
Extension=.otf,
Ligatures=Common
]{Mercury-TextG4Roman}

mercury fight flight no ligatures

\end{document}


The list of ligatures on HF&J's site lists fi:

And charmap in Windows shows that character in that font:

Update:

Output of otfinfo:

Update 2:

Changed to LuaLatex, added a features file:

\documentclass[
11pt,
a4paper
]{scrartcl}

\usepackage{filecontents}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures={Common,Rare,Historic}}

\begin{filecontents*}{mercury.fea}
languagesystem DFLT dflt;
languagesystem latn dflt;
# Ligatures
feature liga {
sub \f \i by \fi;
sub \f \l by \fl;
} liga;
\end{filecontents*}

\begin{document}

\setmainfont[
ExternalLocation,
Extension=.ttf,
UprightFont=*-Regular,
ItalicFont=*-Italic,
BoldFont=*-Bold,
BoldItalicFont=*-BoldItalic,
Ligatures=Common
]{Roboto}

roboto fight flight has ligatures

\setmainfont[
FeatureFile=mercury.fea,
ExternalLocation,
Extension=.otf,
Ligatures=Common
]{Mercury-TextG4Roman}

mercury fight flight no ligatures

\end{document}


And ligatures show:

• Welcome! Since the font is commercial, I can't try this myself. What does otfinfo -f <font filename> give you? In particular, does it include the line liga Standard Ligatures. For comparison, the output from otfinfo -f Roboto-Regular.ttf does include this line. This will determine whether or not the option you are trying to enable is supported. If not, all is not necessarily lost but the command's output will tell us more. – cfr Aug 1 '15 at 1:03
• What happens if you replace \defaultfontfeatures{Mapping=tex-text} with \defaultfontfeatures{Ligatures={Common,Rare,Historic}}? – Mico Aug 1 '15 at 1:07
• OK. I finally realised what is probably going on. Hoefler Text almost certainly does contain support for automatic insertion of ligatures. However, it probably provides that information in the form of AAT features. Only Macs can use these. Moreover, I am not sure that LuaTeX/XeTeX still supports them even on Macs. (At least one of them used to do so. ConTeXt certainly did so as well.) At least in the case of Hoefler, this is because the truetype versions were created for Apple originally. See en.wikipedia.org/wiki/Hoefler_Text. I have no idea about Mercury. – cfr Aug 1 '15 at 2:35
• In your MWE, you load Mercury-TextG4Roman, but when you run otfinfo, you're looking into Mercury-TextG1Roman, i.e. not the same font. – Sverre Aug 1 '15 at 20:58
• @Sverre Adobe is not a foundry I consider generous with its information. But discussion of the relative merits of free and commercial fonts doesn’t belong here; sites like typophile.com already have threads on the subject to which you may contribute if you wish. It seems unfair to condemn a whole industry here, where there’s no room for an adequate defense. (And no, I’m not connected to the industry.) – Thérèse Aug 1 '15 at 21:43

With kind help from @cfr, you've established that:

• The font does contain ligature glyphs.
• fontspec can't make use of AAT ligature information even if it's available.

• The font omits OpenType feature data necessary for automatic ligature support.

So what can you do? You can either add the missing mapping data to the font, or create an external OpenType feature file (supported by LuaTeX only) and tell fontspec to use it. Neither is difficult.

Adding Opentype liga Tables Using FontForge

Note: Consult the licensing terms for your font first, etc'.

1. Open up the font file in fontforge.
2. Open up The Element->Font Info dialog from the menu: The listed entries correspond to various OpenType "features", the one you want is named "Standard ligatures" in the list and termed the liga feature in the spec and the output of otfinfo and you already know it's missing from your font, so we need to create the table first, then populate it with the missing data.
3. Hit the "Add Lookup" button and select the type as "standard ligatures".
4. Hit the "Add Subtable" button to create the actual mapping table. double click on the new subtable entry to open its editor view.
5. You should now see the edito dialogue where you setup mappings between character sequences and ligature glyphs: Use the "populate" button to have FontForge deduce the ligatures supported by the font and automaticaly create entries for you. Depending on the font you may need to edit/add entries manually as well. The left-hand column contains the glyph name for the ligature, while the right-hand column contains the individual characters, seperated by spaces.
6. When done, hit Ok twice to go back to the main window again.
7. Save the updated font file with File->Generate Fonts, making sure the type dropbox is set to OpenType(CFF). Beware that the generated font carries the same internal font name as the original (though easy to change), so you must either overwrite the original (remember to backup) in order to avoid loading the old version, or you should specify the font file's path explicitly when loading it with fontspec.
8. You're done.

Adding Opentype liga Tables Using An OpenType Feature File (LuaTeX only)

The fontspec manual has a section on feature files (with a link to the specification) and it includes an example that shows precisely what you're after, e.g. how to to define ligature mappings. So you need only create the feature file and then make use of the FeatureFile option to tell fontspec to load it:

File: another_league.tex

\documentclass{article}
\usepackage{filecontents}
\usepackage{fontspec}

% Alternatively, place this in a mercury.fea file in the same directory
\begin{filecontents*}{mercury.fea}
languagesystem DFLT dflt;
languagesystem latn dflt;
# Ligatures
feature liga {
sub \f \i by \fi;
sub \f \l by \fl;
} liga;
\end{filecontents*}

\setmainfont[
FeatureFile=mercury.fea,
%Ligatures={Common} % on by default
]{Mercury-TextG4Roman}

\begin{document}
fi \symbol{"FB01}

fl \symbol{"FB02}
\end{document}


This example assumes the ligature glyphs exist at their unicode standard location and includes them directly by glyph number for comparison purposes. YMMV.

Edit: Beware that fontspec doesn't stop with an error if there are problems with the FeatureFile option. Mistyping a path, syntax errors in the file, or using an engine other than LuaTeX will quietly cause it to ignore the feature file.

• I added a fontspec feature file and it worked. Thanks to you and @cfr. – Caleb Paul Aug 3 '15 at 18:24