5

I think the output of the following document is wrong

%\the\textdir
\textdir TLT
ab{\textdir TRT ab}\textdir TLT ab

\bye

enter image description here

If I remove at least one of the "unnecessary" \textdir TLT I get the correct result.

If I remove the group around \textdir TRT ab I get the correct result as well.

Is this a bug in LuaTeX? maybe I did not understand LuaTeX's bidirectional typesetting model.

1
  • The last ab appears in the bottom left hand corner of the page, which does catch you by surprise… Apr 10, 2023 at 12:57

1 Answer 1

4

It seems this is a bug in LuaTeX. Hans Hagen suggested in a response this might be due to the fact I'm pushing the node in vertical mode, and indeed adding \leavevmode solve this example.

But it does not solve a more complex situation. For example

\input color

\parskip=20pt

cc{\textdir TRT cc}cc ab\textdir TLT\ \textcolor{green}{end of paragraph}

cc{\textdir TRT cc}cc
ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab\textdir TLT\ \textcolor{red}{end of paragraph}

cc{\textdir TRT cc}cc
ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
ab ab ab ab ab ab ab ab ab ab ab ab\textdir TLT\ \textcolor{blue}{end of paragraph}


ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
cc{\textdir TRT cc}cc
ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
ab ab ab ab\textdir TLT\ \textcolor{yellow}{end of paragraph}

ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
cc{\textdir TRT cc}cc
ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
ab ab ab ab\textdir TLT\ \textcolor{yellow}{end of paragraph}


\bye

produce the following

enter image description here

which implies that the bug only occurs only when the two directional switches are on the same line.

And as David Purton suggested, the missing text appears at the bottom left corner (which I did not notice until he mentioned it). This is the bottom of the page:

enter image description here

FWIW, I couldn't reproduce this bug in LuaMetaTeX (or with ConTeXt to be more precise).

The bug will probably won't get fixed, for backwards compatibility reasons.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .