latex3 / babel

The babel system for LaTeX, LuaLaTeX and XeLaTeX
LaTeX Project Public License v1.3c
124 stars 34 forks source link

Strange effect of rotated box in RTL context (lualatex) #205

Closed seloumi closed 1 year ago

seloumi commented 1 year ago

To rotate box in RTL context we need to change direction twice to obtain a correct result, with no change of text direction result of rotation is faulty. Is there a possibility to get correct result of rotation without changing text direction every time, thanks.

\documentclass{article}
\usepackage{graphicx}

\pagedir  TRT \bodydir TRT \pardir TRT \textdir TRT

\fboxsep=0pt
\def\rotext{\fbox{rotated text}}

\begin{document}

% rotated box in  TLT text direction 
before {\textdir TLT\rotatebox{60}{\textdir TRT\rotext}} after  \qquad 
before {\textdir TLT\rotatebox[origin=r]{60}{\textdir TRT\rotext}} after \qquad 
before {\textdir TLT\rotatebox[origin=r]{-60}{\textdir TRT\rotext}} after

\vspace*{4cm}

% rotated box in  TRT text direction 
before \rotatebox{60}{\rotext} after  \qquad 
before \rotatebox[origin=r]{60}{\rotext} after \qquad 
before \rotatebox[origin=r]{-60}{\rotext} after

\end{document}

test4.log test4.pdf

u-fischer commented 1 year ago

Your example doesn't use babel at all. Your example probably belongs to https://github.com/latex3/latex2e/issues/241

davidcarlisle commented 1 year ago

as @u-fischer says this is not a babel issue.

Any fix has to also work with xetex and pdftex (which as shown in the latex issue currently also fail, but in different ways.

I think your first TRT example is showing the correct output

before \rotatebox{60}{\rotext} after

should rotate around the box reference point (right hand edge of basline)

The second two using the origin key are showing the core graphics code is not taking account of direction at all so is making arbitrarily misplaced output

jbezos commented 1 year ago

Mixing graphics, with coordinate systems whose directionality is always the same, with bidi text is not trivial, because the underlying mechanism is always the same: boxes, whose direction is inherited. I’ve managed to solve some cases, as you know (simple tikz graphics and pict2e) thanks to some tricks based on lua (I think there is no hope in XeTeX).

As formulated, this is not an exactly issue, but rather a feature request.

seloumi commented 1 year ago

@davidcarlisle I think if the rotation should be around the right edge of the box then the rotation direction should also be changed to clockwise.

car222222 commented 1 year ago

I recall, from many years ago, disputing whether the direction of rotations should be reversed when the current direction is R-to-L. It seems logical to me but I guess that @davidcarlisle won that one!
(I have very limited experience of real-world multi-directional typesetting.)

jbezos commented 1 year ago

I‘m closing this issue because it’s now listed in Enhancements requests. This doesn’t mean it’s rejected, just moved to a specific page for enhancements.