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

Allow manually inserted tatweel to stretch with Arabic kashida #243

Open
amarakon opened this issue May 14, 2023 · 8 comments
Open

Allow manually inserted tatweel to stretch with Arabic kashida #243

amarakon opened this issue May 14, 2023 · 8 comments

Comments

@amarakon
Copy link

The kashida feature allows the use of tatweel to achieve justification instead of stretching the width of spaces. I think that manually inserted tatweel should also be stretchable. But there should also be an option to toggle this feature. In the image below, you will see tatweel with dagger alifs above them, but they are not stretched because they are manually inserted.

import-2023-05-14_00:20:10

@jbezos
Copy link
Contributor

jbezos commented May 14, 2023

Please, provide a MWE. Very likely it can be already done by defining a new rule, but I’m not sure.

@amarakon
Copy link
Author

MWE:

\documentclass{article}

\usepackage{multicol}
\usepackage[bidi = basic]{babel}

\babelprovide[
	main,
	import,
	mapdigits,
	justification = kashida,
	transforms = kashida.plain
]{arabic}

\babelfont[arabic]{rm}{Scheherazade New}

\newcommand{\ayah}{^^^^06dd}

\begin{document}

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

\end{document}

import-2023-05-14_17:13:20

You can see, for example that the manually inserted tatweel in the word “ٱلرَّحْمَـٰنِ” (last word on the first line of the first column from the right) is not stretched.

@jbezos
Copy link
Contributor

jbezos commented May 18, 2023

First attempt:

\babelprehyphenation{arabic}{ {0640} }{ kashida=500 }

However, there are now too many tatweels:
image

@amarakon
Copy link
Author

Ideally, there should be the same amount of tatweel before and after the manually inserted tatweel. This way, the dagger alif is in the middle. Also, the kashida should be just as long as every other kashida. Is your example above a fixed length?

@jbezos
Copy link
Contributor

jbezos commented May 22, 2023

there should be the same amount of tatweel before and after the manually inserted tatweel.

Which means there must be an odd number of tatweel, right? That’s not very difficult. But if there is an even number then the diacritic must be shifted horizontally, which is more complicated.

@amarakon
Copy link
Author

Oh, I thought that the tatweel could be any arbitrary length. I did not know that it has to be an integer number of tatweels. Does that mean that even when the justify factor is set to 1, some space-stretching might have to be used to achieve justification?

I think there are two good options of there is an even number:

  1. One more tatweel to the right of the manually inserted tatweel with the diacritic above it than to the left of it; then shift the diacritic to the right by half the width of the tatweel character.
  2. Simply add one more tatweel to the right of the manually inserted tatweel than to the left of it. It will appear mostly centered, but not exactly.

Option 1 seems better, but I don't know if it it could cause problems. Otherwise, option 2 is also fine.

@jbezos
Copy link
Contributor

jbezos commented May 27, 2023

I’m working on it, but I’m stuck with the vertical placement of diacritics. Well, there is a trick (which I’ve already used in the tentative code for the elongated forms), but I’d like investigate other options before.

@jbezos
Copy link
Contributor

jbezos commented Jun 6, 2023

Update. It seems there is a bug in the default renderer (but I’m not yet sure), which misplaces all diacritics if they are ‘marked’ internally to keep track of them. With Harfbuzz it works as expected. So, this feature has to wait a little bit.

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