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

Justification for Arabic #195

Open
be5invis opened this issue Mar 23, 2023 · 4 comments
Open

Justification for Arabic #195

be5invis opened this issue Mar 23, 2023 · 4 comments
Labels
feature request New feature or request help wanted Extra attention is needed layout Related to layout, positioning, etc. text Text layout, shaping, internationalization, etc.

Comments

@be5invis
Copy link

be5invis commented Mar 23, 2023

Justification of Arabic text is very unique. Usually, they do not add whitespace between words. Instead, Arabic text is justified using two ways:

  • Using more "compressed" or "stretchy" variant glyphs. OT have a tag called jalt to provide these alternatives.
  • Stretching the words by inserting Tatweel between letters.

Example of justified Arabic text from ref. Blue shows the swash Kaf, purple is used for the final elongated Alif, orange marks the Returning Yeh (Bari-Ye), and yellow highlights the use of Tatweels inserted.
image

Exmaple of Tatweel insertion:
image

Ref:

@asibahi
Copy link
Contributor

asibahi commented Mar 23, 2023

Potential issues with this :

  • Kashidas inserted between contextual alternatives (which are heavily used in Arabic fonts) break the shaping. Unless you intend to run the shaper afterwards.
  • The example given is ugly looking. Kashida shouldn't be used this heavily.
  • some Arabic fonts make use of justification alternates, which look better but are not widely supported. (only in indesign iirc). but even indesign just applies to EVERYTHING which looks as bad as the example photo.

The naive implementation for kashida insertion shouldn't be the default behavior (for line lengths this long it is almost always better to just stretch and shrink spaces). If it should exist at all it should be an opt-in toggle.

Here is a three-part essay about Arabic justification by Titus Nemeth: https://research.reading.ac.uk/typoarabic/on-arabic-justification-part-1/ which goes over the history and the issues. You'll find one of the historical findings is that native typesetters prefer to stretch spaces and use alternate shape forms rather than inserting kashidas everywhere. kashidas are at best used very sparingly.

Edit : OG post has been edited and my comment was on the pre-edit screenshot. the edit took in some of comments which is appreciated.

@laurmaedje laurmaedje added feature request New feature or request layout Related to layout, positioning, etc. text Text layout, shaping, internationalization, etc. labels Apr 2, 2023
@reknih reknih added the help wanted Extra attention is needed label Jan 1, 2024
@asibahi
Copy link
Contributor

asibahi commented May 14, 2024

I created a (n opinionated) crate to help with this: https://github.com/asibahi/kashida . Maybe you guys can find it useful. It has some custom rules for Arabic and Syriac, but also a generic function for other scripts like N'Ko and Adlam (using Unicode properties!)

While I believe using variable fonts to be the superior justification strategy, this is a useful fallback, before adjusting spaces.

@laurmaedje
Copy link
Member

Thanks @asibahi!

@laurmaedje laurmaedje changed the title Arabic Kashida Justification for Arabic Jul 15, 2024
@davelab6
Copy link

@asibahi that is awesome work!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request help wanted Extra attention is needed layout Related to layout, positioning, etc. text Text layout, shaping, internationalization, etc.
Projects
None yet
Development

No branches or pull requests

5 participants