6

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}

mwe

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

ligature list

And charmap in Windows shows that character in that font:

character map

Update:

Output of otfinfo:

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:

enter image description here

  • 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 01 '15 at 01:03
  • What happens if you replace \defaultfontfeatures{Mapping=tex-text} with \defaultfontfeatures{Ligatures={Common,Rare,Historic}}? – Mico Aug 01 '15 at 01:07
  • re Mico: same result. The fl and fi aren't ligatures. – Caleb Paul Aug 01 '15 at 01:11
  • Their website is hopeless. Not only do they not tell you what features the fonts support, but their online preview feature does not enable even common ligatures for fonts which I am damn sure have them. (I would be astonished if Hoefler does not support ligatures at this point, for example.) – cfr Aug 01 '15 at 01:12
  • Can you try the otfinfo command? That will tell us if the font supports any feature sets at all and, if so, which ones. – cfr Aug 01 '15 at 01:13
  • Hmm, otfinfo -f lists only kern on that file (and for HoeflerText-Roman.otf as well) – Caleb Paul Aug 01 '15 at 01:38
  • Despite my weakness for fonts, I’ve never bought from that designer because, as cfr notes, the website gives too little information. So I’m working in the dark, but it may be that the font contains ligatures yet doesn’t define a feature for them. In that case, https://tex.stackexchange.com/q/142605/7883 would be relevant. – Thérèse Aug 01 '15 at 02:12
  • This essentially means that the opentype fonts have not been constructed as required. The fonts may include the required glyphs, but that's it. They do not contain the settings which make it straightforward to use those glyphs as properly designed fonts do. It is more-or-less like having postscript type1 fonts which simply could not include this information because they are a much simpler format. For an explanation see my answer here. – cfr Aug 01 '15 at 02:28
  • 1
    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 https://en.wikipedia.org/wiki/Hoefler_Text. I have no idea about Mercury. – cfr Aug 01 '15 at 02:35
  • See this answer for more information and changes to fontspec. – cfr Aug 01 '15 at 03:02
  • 1
    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 01 '15 at 20:58
  • @Thérèse I've never come across a commercial foundry for fonts that tells me exactly what glyphs and OpenType features a font has (or what glyphs are activated by what features). That's the main reason why I don't buy any fonts at all. Commercial fonts are primarily meant for designers and novel writers who rarely need anything outside of a-z, A-Z in an upright font. – Sverre Aug 01 '15 at 21:01
  • @Sverre Well... Apple certainly used them as a marketing feature - especially the AAT configuration in Hoefler, which was something of a flagship font. This isn't selling you a font on its own, I know, but it was part of the product they were selling. – cfr Aug 01 '15 at 21:10
  • @Sverre Some foundries provide PDF specimens that show the entire character set and explain the effect of the OpenType features, and some commercial fonts serve special scholarly needs such as proper transcription of unusual languages. You just have to be careful where you buy fonts and have a clear understanding of your needs. – Thérèse Aug 01 '15 at 21:17
  • @Thérèse [Part 1] The best I have come across are foundries which will show you all the glyphs of a font within the Unicode range (but I've never seen a foundry tell what's in the unencoded space, which is where some niceties are hidden), and what OpenType features the font has (without specifying in any detail which effects those features have on the font). As an example, see the foundry for the Adobe fonts, which are probably the best commercial fonts out there. The information for the Minion Pro fonts, ... – Sverre Aug 01 '15 at 21:29
  • @Thérèse [Part 2] for example, will not tell you that the OpenType feature liga will activate a ligature for Th. I consider such information quite important, especially when the Th ligature isn't considered "standard" by anyone outside of Adobe. (Since I am myself a scholar of linguistics and philology, the best fonts I can think of are the SIL fonts, Junicode, and Brill, all free). – Sverre Aug 01 '15 at 21:34
  • 1
    @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 01 '15 at 21:43
  • We'd like to keep answers separate from questions, so you should write a separate answer instead of editing your answer into the question. Self-answers are perfectly admissible, and a well-written answer may earn you additional reputation. It's also ok to demonstrate with a separate answer that the accepted answer indeed works (I've done that myself). – Sverre Aug 03 '15 at 20:18

1 Answers1

11

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: Font Info Dialog 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: Ligature subtable editor 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{&quot;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.