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

mplibcode is not bidi aware #129

Open
u-fischer opened this issue Apr 24, 2024 · 1 comment
Open

mplibcode is not bidi aware #129

u-fischer opened this issue Apr 24, 2024 · 1 comment

Comments

@u-fischer
Copy link

(extracted from https://tex.stackexchange.com/questions/716319/has-anything-gone-wrong-with-mpchess)

mplibcode is not bidi aware. In the following example, the content of the mplibcode spills out of the bounding box if the direction is set to TRT:

\documentclass{book}
\usepackage{luamplib}

\usepackage{fontspec}
\setmainfont{amiri}
\begin{document}\showoutput
\pardir TRT \textdir TRT

هذا النص يمكن أن يتم تركيبه على أي تصميم دون مشكلة فلن يبدو وكأنه نص منسوخ، غير منظم، غير منسق، أو حتى غير مفهوم. لأنه مازال نصاً بديلاً ومؤقتاً.
\fbox{\begin{mplibcode}
beginfig(0);
color red ; red = (1, 0, 0) ;
fill (0,0)--(100,0)--(100,100)--(0,100)--cycle withcolor red;
endfig;
\end{mplibcode}}
هذا النص يمكن أن يتم تركيبه على أي تصميم دون مشكلة فلن يبدو وكأنه نص منسوخ، غير منظم، غير منسق، أو حتى غير مفهوم. لأنه مازال نصاً بديلاً ومؤقتاً.

\end{document}

image

everything is fine without the \pardir TRT \textdir TRT:

image

@dohyunkim
Copy link
Contributor

Thanks for the report.
The following patch seems to solve the problem.

diff --git a/usr/local/texlive/2024/texmf-dist/tex/luatex/luamplib/luamplib.sty b/texmf/tex/luatex/luamplib/luamplib.sty
index 6655770..2ce00a4 100644
--- a/usr/local/texlive/2024/texmf-dist/tex/luatex/luamplib/luamplib.sty
+++ b/texmf/tex/luatex/luamplib/luamplib.sty
@@ -202,7 +202,7 @@
 \ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi
 \def\mplibstarttoPDF#1#2#3#4{%
   \prependtomplibbox
-  \hbox\bgroup
+  \hbox dir TLT\bgroup
   \xdef\MPllx{#1}\xdef\MPlly{#2}%
   \xdef\MPurx{#3}\xdef\MPury{#4}%
   \xdef\MPwidth{\the\dimexpr#3bp-#1bp\relax}%

As for RTT mode (CJK vertical writing), the bounding box still does not match.
But as packages luatexko and luatexja do not seem to use RTT mode, I will leave it as it is.
A new version will be uploaded soon.

@dohyunkim dohyunkim mentioned this issue Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants