[luatex] \enddir

Taco Hoekwater taco at elvenkind.com
Thu Dec 13 11:11:50 CET 2012


On 12/13/2012 09:38 AM, Joseph Wright wrote:
> Hello all,
>
> If you insert something like
>
>    \hbox{\textdir TRT ABC}
>
> and look at the shipout, you get
>
>    ..\hbox(6.83331+0.0)x21.8056, direction TLT
>    ...\begindir TRT
>    ...\tenrm A
>    ...\tenrm B
>    ...\tenrm C
>    ..\glue 0.0 plus 1.0fill
>
> On the other hand, adding a group
>
>    \hbox{{\textdir TRT ABC}}
>
> leads to
>
>    ..\hbox(6.83331+0.0)x21.8056, direction TLT
>    ...\begindir TRT
>    ...\tenrm A
>    ...\tenrm B
>    ...\tenrm C
>    ...\enddir TRT
>    ..\glue 0.0 plus 1.0fill
>
> which includes an \enddir. Both of these seem to work the same way in
> practice (the direction does not 'leak' from the first case), but I
> wonder if the \enddir has any importance.

Normally, the code that exports the box to PDF/DVI takes care of
closing up the open direction nodes based on the box's 'box direction'.
But if there is a group involved, then the box does not give enough
hints, hence the explicit \enddir in that case.

The missing \enddir is a number-of-nodes optimization from Omega that
Hans is not too happy about as it is both confusing and makes it a
little hard to process the node list directions in lua, so it will
likely go away at some point, and explicit \enddirs will be present
always at some point in the future.

> For testing, I tried
>
>    \hbox{\textdir TRT ABC\textdir TLT D}
>
> which gives the slightly odd
>
>    ..\hbox(6.83331+0.0)x29.4445, direction TLT
>    ...\begindir TRT
>    ...\tenrm A
>    ...\tenrm B
>    ...\tenrm C
>    ...\begindir TRT
>    ...\begindir TLT
>    ...\tenrm D
>    ..\glue 0.0 plus 1.0fill
>
> (Can't imagine this is deliberate.)

Code copied from Omega, and there were no comments in that code
anywhere, so I just kept it as is originally. But it does look
weird, so I made a local change to produce \enddir TRT instead
of the second \begindir TRT. For this source:

   (\hbox{\textdir TRT ABC\textdir TLT DEF})

The change actually changed the output PDF from (old):

   (DEFCBA)

to (new)

   (CBADEF)

which to my layman's eyes appears to make more sense (the second 
\textdir now actually replaces the first, instead of starting an
implied direction group).

But then, I find the direction stuff utterly confusing, so before I
commit the change, I would really like a second opinion.

Best wishes,
Taco



















More information about the luatex mailing list