# Letters after discretionary disappear (seems an issue of package fontspec)?

For the following case,

% !TeX program = xelatex
\documentclass[12pt]{article}
\usepackage{fontspec}

\begin{document}
\hsize =2in
shelf{}ful shelf{}ful shelf\-ful di\discretionary{f-}{fi}{f\kern0ptfi}cult
\end{document}


I get,

Actually, if there's a kern followed by anything in the third argument of \discretionary, letters after it disappear, but when I don't use the package fontspec, nothing goes wrong. Is this a bug?

• It's not fontspec. If I do the same with xetex, the problem shows as well. – egreg Jan 24 '17 at 15:44
• Neat. But it is not a fontspec problem. You see the same problem if you don't load fontspec and call the font as \font\test="[lmroman12-regular.otf]"\test – Ulrike Fischer Jan 24 '17 at 15:44
• raised as sourceforge.net/p/xetex/bugs/137 – David Carlisle Jan 24 '17 at 20:40

This seems a bug in XeTeX. If there's something which is not a letter in the “nobreak” argument to \discretionary and a break is taken, the word part following the discretionary disappears.

Minimal example:

\input ifxetex.sty

\ifxetex
\font\test="Latin Modern Roman:mapping=tex-text" at 12pt
\else
\font\test=ec-lmr12
\fi
\test


Compile with xetex and the result is
If compiled with pdftex we get the expected result:
• The problem appears only if the \kern or {} is between two letters in the “nobreak” argument. Note also that {} doesn't break ligatures when an OpenType/TrueType font is used. – egreg Jan 24 '17 at 16:07