Closed hubaishan closed 1 year ago
Sure. See https://latex3.github.io/babel/news/whats-new-in-babel-3.59.html (“Of course, these setting must be also font dependent”). Since the orthographical and typographical rules are not exactly the same for all languages in the Arabic script, the rules have to depend on both font and language.
As a workaround and with the help of lua attributes, it’s now possible a minimal control on when to apply a transform. The following example show how to restrict it to an attribute and how to set (or unset) it depending on the font family. (This is a preliminary work for a more complete support.)
\documentclass{article}
\usepackage[arabic, bidi=basic, provide=*]{babel}
\babelprovide[justification=kashida]{arabic}
\usepackage{multicol}
\babelfont{rm}{FreeSerif}
\babelfont{sf}{DejaVu Sans}
\newattribute{\rmarab}
\AddToHook{rmfamily}{\setattribute{\rmarab}{1}}
\AddToHook{sffamily}{\unsetattribute{\rmarab}}
\babelprehyphenation[attribute=\rmarab]{arabic}{
{a}
() [ي ئ ه ش س ق ف غ ع ض ص ن م ل ك ظ ط خ ح ج ث ت ب ڢ] ()
[ي ئ ه ق ن ك ث ت ب ا أ إ آ و ؤ ذ د ز ر ة]
[|،,{.}){]}] }
{ kashida = 500 }
\babelprehyphenation[attribute=\rmarab]{arabic}{
() ل () [ ا أ إ آ] }{ kashida = 0 }
\begin{document}
\begin{multicols}{4}
يختلف طراز المساكن بشكل كبير من بلد إلى آخر، كما أن نمط بناء المساكن قد
تغير بمرور الزمن. ويحمل كثير من أنماط البناء اسم البلد أو الحقبة
الزمنية التي شيد فيها، بينما تحمل أنماط أخرى أسماء المهندسين المعماريين
الذين قاموا بتصميمها. ويشتمل طراز البناء الأوروبي التاريخي على فن
العمارة الرومانسكي، والطراز القوطي، وطراز عصر النهضة، والباروكي، وطراز
الروكوكو.
\end{multicols}
\sffamily
\begin{multicols}{4}
يختلف طراز المساكن بشكل كبير من بلد إلى آخر، كما أن نمط بناء المساكن قد
تغير بمرور الزمن. ويحمل كثير من أنماط البناء اسم البلد أو الحقبة
الزمنية التي شيد فيها، بينما تحمل أنماط أخرى أسماء المهندسين المعماريين
الذين قاموا بتصميمها. ويشتمل طراز البناء الأوروبي التاريخي على فن
العمارة الرومانسكي، والطراز القوطي، وطراز عصر النهضة، والباروكي، وطراز
الروكوكو.
\end{multicols}
\end{document}
Some fonts may be better with kashida justification and other with elongated justification. So it is better for multifont document to choose justification mode by font.