# Incorrect LuaTeX ligatures

I have a problem with LuaLaTeX (from TL 2016: Version 0.95.0 (TeX Live 2016) (format=lualatex 2017.1.29)) making inappropriate ligatures. Here goes the MWE:

\documentclass[a4paper, 12pt]{article}
\def\czechSingleQuotes #1{‚#1‘} % UTF-8 chars for single quotes
\begin{document}
\czechSingleQuotes{Ahoj!}

\czechSingleQuotes{Nazdar?}

‚Hi!‘
\end{document}


The result looks like this:

I hope LuaTeX guys are reading it here and will do something about it. However, would anyone have any suggestion as how to work around this until it gets fixed? Usual (in different situations) tricks do not help, e.g. \def\czechSingleQuotes #1{‚{#1}{}\relax ‘} produces the same result.

Later EDIT: This has been fixed in the newest luaotfload (v2.8-fix-1) however the fix seems to be going a little too far — now even the standard ligatures to create reverted Spanish exclamation or question marks do not work any more, so that this:

\documentclass[a4paper, 12pt]{article}
\begin{document}
Hi? % standard back apostrophe, no UTF-8

Hi! % ditto
\end{document}


creates different outputs in LuaTeX (standard q./ex. marks followed by a back quote) and in XeTeX or pdfTeX (Spanish reverted q./ex. marks).

• It’s fine in ConTeXt, so it’s fixable. \starttext ‚Hi!‘ \stoptext – Henri Menke Jan 31 '17 at 19:27
• Note that LuaTeX, unlike pdfLaTeX, discards {}. Insert a zero-width \kern -- it's never discarded. – Mico Jan 31 '17 at 19:37
• @DavidCarlisle: OK, thx, I'll report it probably tomorrow. – Marcel S. Jan 31 '17 at 19:49
• seems to be a luaotfload issue (although still with the version in today's texlive update) – David Carlisle Jan 31 '17 at 19:57
• – David Carlisle Jan 31 '17 at 20:30

As David Carlisle has pointed out in comment, the "classic" TeX ligatures for inverted question and exclamation marks are being applied even though "typographic" quotes, rather than basic back quotes, are present.

Inserting the instruction \kern0pt before the closing quote is an effective remedy. Note that LuaTeX, unlike pdfLaTEX, discards {} elements. Hence, you can't use {} to create some invisible separation between the punctuation marks and the typographic quotes.

\documentclass{article}
\def\czechSingleQuotes#1{‚#1\kern0pt‘} % UTF8 chars for single quotes
\begin{document}
% "classic" TeX ligatures applied even though "typographic" quotes are in use
? ? ?‘ --- ! ! !‘

\czechSingleQuotes{Ahoj!}

\czechSingleQuotes{Nazdar?}

\czechSingleQuotes{Hi!!}
\end{document}

• it seems to be using classic tex ligatures for ? even though typographic quotes have been used. – David Carlisle Jan 31 '17 at 19:39
• @DavidCarlisle - Excellent point! I'll provide this insight in the body of my answer, if I may. – Mico Jan 31 '17 at 19:41
• @Mico: Thx, this workaround seems to do the trick. I do not write Spanish much and if so, I just enter those inverted question or exclamation marks directly, therefore I didn't even know those ligatures. – Marcel S. Jan 31 '17 at 19:53

The TeX ligatures are being mis-applied, you can use fontspec to turn them off, although for example that means that --- would no longer ligature to an mdash.

\documentclass[a4paper, 12pt]{article}
\usepackage{fontspec}
\def\czechSingleQuotes #1{‚#1‘} % UTF-8 chars for single quotes
\defaultfontfeatures[\rmfamily]{}
\setmainfont{Latin Modern Roman}
\begin{document}
\czechSingleQuotes{Ahoj!}

\czechSingleQuotes{Nazdar?}

‚Hi!‘
\end{document}


This is a luaotfload issue as this plain tex test shows, I'll report to the github.

\input{luaotfload.sty}

\font\fa=[lmroman12-regular.otf]
\font\fb=[lmroman12-regular.otf]:+tlig

\fa

U+2018 no tlig !‘

U+0060 no tlig !

\fb

U+2018 tlig !‘

U+0060  tlig !

\bye
`