Fonts/Ligatures
Contents
Introduction
Ligatures are combinations of letters that use different glyph shapes to avoid clashing of parts like i-dots and f-arcs. Many fonts contain at least fi and fl ligatures, well-furnished fonts have also ft, ffl, ffi, fft, fb, ffb, fh, ffh and maybe some traditional ones like st, sp, ct, ch and combinations with long s – German ß was originally a long-s + end-s ligature (even if it looks like s+z and is called szlig).
While the use of ligatures is a feature of good typography, there are places where they don’t belong, namely at syllable seams where hyphenation can or should take place.
Some typical German examples are Auf-lage, auf-laden, auf-fallen, Zupf-instrument, Schiff-fahrt. English examples would be chief-ly, shelf-ful, elf-like, wolf-trap, clothes-pin.
Traditional TeX methods to break ligatures
- Auf\/lage – breaks the ligature, but also kills hyphenation and kerning
- Auf{}lage – worked in pdfTeX (MkII), but not in modern TeX engines
- For LaTeX, there’s the selnolig package (English and German).
Enabling Ligatures in fonts
Ligatures in OpenType fonts are defined via "features" that you can/must enable. Usual ligature features are liga and tlig, but some fonts my have others for more/exotic ligatures. Here’s an example for a good set of default features:
\definefontfeature[default] [mode=node,kern=yes, liga=yes,tlig=yes, ccmp=yes,language=dflt, protrusion=quality, expansion=quality]
The other way round – if you don’t enable ligatures in your font features, you won’t get any; this might be desirable for mono width (typewriter) fonts.
Single places
If you only want to fix a few occurrences, you can use \noligature. Compare:
Auflage Zupfinstrument Au\noligature{fl}age Zup\noligature{fi}nstrument
Replacements
ConTeXt has a method of replacing words that you can use for ligature exception dictionaries:
\mainlanguage[de] \definefontfeature[default] [mode=node,liga=yes,kern=yes,tlig=yes, ccmp=yes,language=dflt, protrusion=quality, expansion=quality] \replaceword[eg][Auflage][Au{fl}age] \replaceword[eg][Zupfinstrument][Zup{fi}nstrument] \starttext Auflage Zupfinstrument \setreplacements[eg] Auflage Zupfinstrument \stoptext
Much better. The first parameter os \replaceword is a set (collection) keycode, i.e. you can define different sets of replacements and activate them with \setreplacements.
Here’s a list of German ligature exceptions, derived from selnolig LaTeX package. Just \input it in your environment.
In current versions (after 2017-09-28) you may also define several exceptions at once, like
\replaceword [eg] [Au{fl}age Schiff{f}ahrt Zup{fi}nstrument]
Find more details in the source: lang-rep.mkiv
Blocking
You can also define blocking of ligatures as a font feature:
\blockligatures[fi,ff] \blockligatures[fl] \blockligatures[au:fl:age] \definefontfeature[default:nolig][default][blockligatures=yes] \definedfont[Serif*default:nolig] % no ligatures fi ff fl Auflage Zupfinstrument \definedfont[Serif*default] % yes ligatures fi ff fl Auflage Zupfinstrument
While general blocking (\blockligatures[fi,fl]) works, the exception handling (\blockligatures[au:fl:age]) might depend on a version unpublished as of this writing (i.e. after 2017-09-28).
Word suppression
In English, one principle suggests not using specific ligatures in certain words because ligatures should not cross morpheme boundaries. For instance, the fi ligature in wolfish is to be suppressed because the f and i belong to distinct morphemes (wolf and ish, in contrast to fish, where fi is a single morpheme). The following code shows how to apply this rule to prevent unwanted ligatures:
\setuplanguage[en][goodies={lang-en.llg}] \starttext wolfish huffily puffily \stoptext
Other languages will need a corresponding ligature suppression word list.