latex3 / babel

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

Not enough lam-alif exceptions for kashida justification #216

Closed amarakon closed 1 year ago

amarakon commented 1 year ago

I like to use kashida justification when using arabic. What's new in babel 3.59 states:

A very simple and basic transform for arabic and persian is included for ‘plain’ Arabic fonts, which attempts to distribute the tatwil as evenly as possible. It’s named kashida.plain (with precedence 500) and no ligature is taken into account (except, of course, for the lam-alif).

I think the code that makes the lam-alif an exception is this:

\babelprehyphenation{arabic}{ () ل () [ ا أ إ آ] }{ kashida = 0 }

However, it does not account for if there is a fatḥah above the lam. I will give a minimum working example with the first surah from the Quran:

\documentclass{book}

\usepackage[bidi = basic]{babel}
\usepackage[paperwidth = 1in, paperheight = 6in]{geometry}

\babelprovide[main, import, mapdigits, justification = kashida, transforms = kashida.plain]{arabic}
\directlua{Babel.arabic.justify_factor = 1}
\babelfont[arabic]{rm}[Renderer = HarfBuzz, Scale = 1.1]{Kitab}

\def\ayah{^^^^06dd}

\begin{document}

بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ~\ayah1
الْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ~\ayah2
الرَّحْمَٰنِ الرَّحِيمِ~\ayah3
مَالِكِ يَوْمِ الدِّينِ~\ayah4
إِيَّاكَ نَعْبُدُ وَإِيَّاكَ نَسْتَعِينُ~\ayah5
اهْدِنَا الصِّرَاطَ الْمُسْتَقِيمَ~\ayah6
صِرَاطَ الَّذِينَ أَنْعَمْتَ عَلَيْهِمْ غَيْرِ الْمَغْضُوبِ عَلَيْهِمْ وَلَا الضَّالِّينَ~\ayah7
\end{document}

import-2023-01-22_01:19:17

jbezos commented 1 year ago

Is the font the one that is available here?: https://quranacademy.gitbook.io/digital-quran/content-and-release-plan/font-kitab

With it, it works fine for me. If the font is different, please let me know where I can find it. On the other hand, the lam-alif was buggy originally, indeed, but I fixed in v. 3.75. Which version are you using?

Actually, the transform kashida.plain is defined in the ini file, which currently reads:

kashida.plain.1.0 = { ()[يئهشسقفغعضصنمكلظطخحجثتب]()[ًٍَُِّ]*[يئهشسقفغعضصنمكلظطخحجثتباأإآوؤذدزرة] }
kashida.plain.1.1 =   { kashida = 500 }
kashida.plain.2.0 = { ()ل()[ًٍَُِّ]*[اأإآ] }
kashida.plain.2.1 =   { kashida = 0 }
amarakon commented 1 year ago

Is the font the one that is available here?: https://quranacademy.gitbook.io/digital-quran/content-and-release-plan/font-kitab

Yes. Sorry for forgetting to link the font in my issue.

With it, it works fine for me. If the font is different, please let me know where I can find it. On the other hand, the lam-alif was buggy originally, indeed, but I fixed in v. 3.75. Which version are you using?

You're right, I was using an earlier version of babel which is bundled with TeXLive 2022: 3.73. I updated to v3.85 and that fixes the issue.

jbezos commented 1 year ago

Glad to know it's working.