# In lualatex, hyphenation doesn't seem to work for words that contain certain ligatures

It would seem that hyphenation does not work properly under LuaLaTeX if the hyphenation points occur at places where TeX inserts ligatures. Consider the following MWE, which (i) provides hyphenation points for seven selected words and (ii) prints them using a very narrow measure (in order to force TeX to use all possible hyphenation points):

% !TEX program = lualatex
\documentclass[letterpaper]{article}
\usepackage[hmargin=4.2in]{geometry}
\setlength\parindent{0pt}
\usepackage[no-math]{fontspec}
\setmainfont{EB Garamond}
\hyphenation{white-space Keynes-ian dwarf-ish calf-like wolf-fish ruff-like roof-top}
\begin{document}
whitespace Keynesian dwarfish calflike wolffish rufflike rooftop
\end{document}


I chose the font "EB Garamond" because it provides the ft ligature as well as the "standard five" f-ligatures (ff, fi, fl, ffi, and ffl). The output of the MWE looks like this:

Observe that the first two words in the list, whitespace and Keynesian, are hyphenated correctly. In case you're curious: without help from the \hyphenation command, TeX would hyphenate these two words as whites-pace and Key-ne-sian. Yikes!

However, the five other words are not hyphenated at all despite the fact that explicit hyphenation points are supplied. [Aside: When run under either pdflatex (without loading the fontspec package, obviously) or XeLaTeX, this MWE runs correctly, i.e., the words are hyphenated at the specified hyphenation points.] The thing these words have in common is that they all contain ligatures that cross the specified hyphenation points. This makes me think that LuaLaTeX replaces various character pairs (or triples) with ligatures before it considers hyphenation possibilities.

What strengthens my belief in the correctness of this diagnosis is that if I use the font "Latin Modern" (which does not contain the "ft" ligature) instead of "EB Garamond", the word "rooftop" is once again hyphenated correctly, whereas the remaining four words with f-ligatures (i.e., dwarfish, calflike, wolffish, and rufflike) still aren't hyphenated at all. Likewise, when I load the font "Aldus LT Std" -- which only has the "fi" and "fl" ligatures, but no "ff", "ffi", "ffl", or "ft" ligatures -- the word "wolffish" is hyphenated as well, whereas "dwarfish", "calflike", and "rufflike" still aren't hyphenated.

Somewhat surprisingly, I've discovered that if I comment out the instruction \usepackage{fontspec}, hyphenation does work once again in LuaLaTeX. However, if the fontspec package is not loaded explicitly, one can't access fonts other than "Computer Modern".

Questions: Has LuaLaTeX's hyphenation algorithm changed recently, and/or has fontspec changed recently? (Decidedly for the worse, I'm tempted to say...) Alternatively, has the \hyphenation command become obsolete? If it's the latter, which command should I be using instead to specify hyphenation points?

• When fontspec is not loaded, the default font is cmr10, not Latin Modern. This seems a bug with OpenType fonts: it fails with all ligatures. – egreg Mar 6 '12 at 20:38
• Looks like a luaotfload bug when in node mode, with Renderer=Basic (base mode) fontspec option I get the hyphenation correctly. – Khaled Hosny Mar 6 '12 at 21:28
• @egreg: Thanks for pointing out this mistake; I will correct the write-up. Please consider posting your comment as an answer so that I can upvote it. – Mico Mar 6 '12 at 21:29
• @KhaledHosny: Thanks for zeroing in on the source of the bug. Please consider posting your comment (possibly with a bit more information on how to select the alternative manner of loading the luaotfload package) as an answer so that I can upvote it. – Mico Mar 6 '12 at 21:43

Elaborating on my comment above, this seems like a bug in luaotfload when in node mode (the default font rendering mode which does more faithful OpenType processing), switching to base mode fixes it (a more limited rendering mode that tries to map OpenType font feature to legacy TeX ligaturing mechanism as far as possible), for example:

% !TEX program = lualatex
\documentclass[letterpaper]{article}
\usepackage[hmargin=4.2in]{geometry}
\setlength\parindent{0pt}
\usepackage[no-math]{fontspec}
\setmainfont[Renderer=Basic]{EB Garamond}
\hyphenation{white-space Keynes-ian dwarf-ish calf-like wolf-fish ruff-like roof-top}
\begin{document}
whitespace Keynesian dwarfish calflike wolffish rufflike rooftop
\end{document}


Renderer=Basic tells fontspec to use base mode.

This can be a bug inherited from ConTeXt font code that luaotfload re-packages for LaTeX and Plain, but not yet confirmed.

If you only need basic ligatures (and may be kerning, not sure), then basic mode should be enough until this bug is solved.

I opened a luaotfload issue to keep track of this bug.

• A "status report" of sorts on this issue: Using TeXLive2014/pre, the Renderer=Basic option is no longer needed to get hyphenation across potential ligatures if EB Garamond is in use. However, this may be due more to some improved capabilities of EB Garamond than to structural improvements in luaotfload. For sure, the Renderer=Basic option is still needed if many other fonts -- say, Latin Modern Roman, XITS, and Calibri -- are used. (Of course, XITS doesn't feature an ft ligature and hence there's no problem with hyphenating "rooftop" for that font.) – Mico May 17 '14 at 18:43
• @Mico Yes, and you have to check the output carefully even for EB Garamond: “dwarfish” is hyphenated in the right place, but the dot on the i disappears from the PDF (copying and pasting does give “dwarf-ish”). – Thérèse Aug 21 '15 at 3:14
• @Thérèse - Thanks for pointing out the missing dot on the "i" in [dwarf-]ish. Probably something for Georg Duffner (the author of EB Garamond) to look into. – Mico Aug 21 '15 at 18:41