Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

enter image description here

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?

share|improve this question
2  
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
7  
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
1  
@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
add comment

1 Answer

up vote 15 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.