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?
Best Answer
Elaborating on my comment above, this seems like a bug in
luaotfload
when innode
mode (the default font rendering mode which does more faithful OpenType processing), switching tobase
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:Renderer=Basic
tells fontspec to usebase
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.