4

Consider this example, why the result is uncorrect and how to fix it

\documentclass{article}
\usepackage[bidi=basic-r]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelfont{rm}{Amiri}

\begin{document}

\setbox0=\hbox{نص عربي}

\unhbox0

\end{document}

enter image description here

  • 1
    You probably need to explicitly set the text direction in this case, since automatic bidi won’t work with output glyphs (the input charter information it needs is lost at this point). – Khaled Hosny Aug 22 at 20:18
  • @KhaledHosny I tried with \textdir TRT \unhbox0 but this doesn't solve the problem. – Salim Bou Aug 22 at 20:41
  • No idea what is going on, but this works without babel \setbox0=\hbox{\textdir TRT نص عربي}\unhbox0 (you need to set the direction inside the box, setting it outside is ignored by the box). – Khaled Hosny Aug 22 at 22:20
4

The problem is Amiri uses the Private Use Area. Once the box is built, there is no information about the direction of the glyphs. If the direction is set explicitly with \babelcharproperty (I don't know the exact range), the text is rendered correctly:

\documentclass{article}
\usepackage[bidi=basic]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelfont{rm}{Amiri}

% The following range is just a guess:
\babelcharproperty{980000}[990000]{direction}{al}

\begin{document}

\setbox0=\hbox{نص عربي}

\unhbox0

\end{document}

You may use this macro as a workaround, but I must investigate a better solution.

  • Yes the issue appears only with Amiri font, thanks. – Salim Bou Aug 23 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.