Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWE: \hbox in RTL issue #1796

Open
mahmadzaid opened this issue May 5, 2023 · 2 comments · May be fixed by #1822
Open

MWE: \hbox in RTL issue #1796

mahmadzaid opened this issue May 5, 2023 · 2 comments · May be fixed by #1822
Labels
bug Software bug issue

Comments

@mahmadzaid
Copy link

\begin[papersize=b6,class=plain]{document}
\use[module=packages.frametricks]
\use[module=packages.rules]
\nofolios
\neverindent
\define[command=cmnt]{\breakframevertical\font[size=0.8em]{\process}\smallskip}
\define[command=rtlframe]{\breakframevertical\thisframedirection[direction=RTL]}
\define[command=ltrframe]{\breakframevertical}
\font[family="Amiri",size=12pt]


\cmnt{LTR language:}
\cmnt{- In a LTR frame:}
\ltrframe
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Lorem ipsum dolor sit amet, \hbox{consectetur adipiscing} elit, sed do eiusmod tempor \hbox{incididunt} ut labore et dolore magna aliqua.

\bigskip

\cmnt{- In a RTL frame:}
\rtlframe
Lorem ipsum dolor sit amet, \hbox{consectetur adipiscing} elit, sed do eiusmod tempor \hbox{incididunt} ut labore et dolore magna aliqua.

\medskip\fullrule\medskip

\cmnt{RTL language:}
\cmnt{- In a RTL frame:}
\rtlframe
عندما يريد العالم أن يتكلّم، فهو يتحدّث بلغة unicode.

عندما يريد العالم أن يتكلّم، فهو يتحدّث بلغة \hbox{unicode}.

عندما يريد العالم أن يتكلّم، فهو يتحدّث بلغة يونيكود.

عندما يريد العالم أن يتكلّم، فهو يتحدّث بلغة \hbox{يونيكود}.

\bigskip

\cmnt{- In a LTR frame:}
\ltrframe
عندما يريد العالم أن يتكلّم، فهو يتحدّث بلغة unicode.

عندما يريد العالم أن يتكلّم، فهو يتحدّث بلغة \hbox{unicode}.

عندما يريد العالم أن يتكلّم، فهو يتحدّث بلغة يونيكود.

عندما يريد العالم أن يتكلّم، فهو يتحدّث بلغة \hbox{يونيكود}.

\end{document}

image

@mahmadzaid
Copy link
Author

Putting this here for reference as I try to fix find a workaround for the remaining issue, which I suspect is in the bidi package:

diff --git a/typesetters/base.lua b/typesetters/base.lua
index 6c65848..cea1692 100644
--- a/typesetters/base.lua
+++ b/typesetters/base.lua
@@ -936,7 +936,6 @@ function typesetter:makeHbox (content)
       depth = d,
       value = recentContribution,
       outputYourself = function (box, atypesetter, line)
-        local _post = _rtl_pre_post(box, atypesetter, line)
         local ox = atypesetter.frame.state.cursorX
         local oy = atypesetter.frame.state.cursorY
         SILE.outputter:setCursor(atypesetter.frame.state.cursorX, atypesetter.frame.state.cursorY)
@@ -945,7 +944,7 @@ function typesetter:makeHbox (content)
         end
         atypesetter.frame.state.cursorX = ox
         atypesetter.frame.state.cursorY = oy
-        _post()
+        atypesetter.frame:advanceWritingDirection(box:scaledWidth(line))
         SU.debug("hboxes", function ()
           SILE.outputter:debugHbox(box, box:scaledWidth(line))
           return "Drew debug outline around hbox"

image

@mahmadzaid
Copy link
Author

And here for the bidi part (WIP):

diff --git a/packages/bidi/init.lua b/packages/bidi/init.lua
index b9eab11..c507cc2 100644
--- a/packages/bidi/init.lua
+++ b/packages/bidi/init.lua
@@ -204,6 +204,13 @@ function package.reorder (_, n, typesetter)
     if nl[i].is_nnode and levels[i].level %2 ~= base_level then
       SU.flip_in_place(nl[i].nodes)
       reverse_each_node(nl[i].nodes)
+    elseif nl[i].is_hbox and levels[i].level %2 ~= base_level and not nl[i].bidiDone then
+      for j = 1, #nl[i].value do
+        if nl[i].value[j].is_nnode then
+          SU.flip_in_place(nl[i].value[j].nodes)
+          reverse_each_node(nl[i].value[j].nodes)
+        end
+      end
     elseif nl[i].is_discretionary and levels[i].level %2 ~= base_level and not nl[i].bidiDone then
       for j = 1, #(nl[i].replacement) do
         if nl[i].replacement[j].is_nnode then

image

@mahmadzaid mahmadzaid linked a pull request Jun 25, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Software bug issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants