3

I am trying to find out how to have Kashida justification in Luatex (in TexLive) for bidi text.

Background:

  • I can see by searching that support might appear in babel here but nothing implemented yet.
  • In Xetex (bidi or xeperisan ?), Kashida justification is implemented by \XetexInterCharToks, using \hrule but not the glyph ( which was visually problematic in letter joints).
  • Using (stretching) the Kashida glyph directly or applying the new variable fonts feature are the two alternatives.
  • I also noticed that \XetexInterCharToks can be implemented in Luatex in someway here.
  • Previously, I asked about finding the width of glue space between chars here.
  • No idea, if harfbuzz implementation (any support for Kashida ?) can be related. Harfbuzz can be used through luahbtex here

Edit (About Kashida):

Kashida (from keshideh which means "stretched" in Persian) is a dash-like justification that can be added between (actually to the end of the first letter) some letters in Arabic/Persian/Urdu scripts (and probably Hebrew see here). Its Unicode character is (U+0640), also known as Arabic Tatweel.

It has two functionalities:

  1. aesthetically: more beautiful typesetting and a replacement for white-space justification
  2. It can be used in stressing some words, as a replacement for capital letters or small-caps which do not exist in those scripts.

One can add manually the default character ((U+0640)) as many time as it seems appropriate:

کشیده
vs
کشیـــــــده

However, (1) any use of Kashida letter might create problem when searching for a word, and (2), the right amount of width of Keshida is not a proper multiple of the default width of it in a font. Therefore, a right solution might be to use variable fonts technology. This also can fix another problem that Kashida is not always a stretchable dash but it can be/should be a stretchable curve part of a glyph.

Shahryar
  • 365
  • 3
  • 9
  • 2
    You can't implement \XetexInterCharToks in LuaTeX like this anymore because the token_filter callback is gone. – Henri Menke Dec 11 '19 at 06:35
  • 1
    in luatex rather than using interchar tokens and two runs to see the stretched glue you could probably do it in one pass by adjusting a glue node in the post linebreak callback – David Carlisle Dec 11 '19 at 07:50
  • 1
    for harfbuzz you probably want to watch this issue https://github.com/harfbuzz/harfbuzz/issues/586 – David Carlisle Dec 11 '19 at 07:53
  • 1
    What is Kashida? I can guess from your question that it has something to do with spaces but the rules are unclear. – Ulrike Fischer Dec 11 '19 at 07:55
  • 1
    @UlrikeFischer stretchy line-y character thing that can stretch to avoid stretching space. https://en.wikipedia.org/wiki/Kashida – David Carlisle Dec 11 '19 at 07:57
  • 1
    http://tug.org/tug2019/abstracts/anane-arabicmf.txt -- http://tug.org/tug2019/slides/slides-anane.pdf – Henri Menke Dec 11 '19 at 07:59
  • @DavidCarlisle is this the callback you mentioned? http://wiki.luatex.org/index.php/Post_linebreak_filter – Shahryar Dec 11 '19 at 08:51
  • @DavidCarlisle I have looked at those issues, but could not figure out if in Luatex environment this is the responsibility of Luatex or Harfbuzz to decide about using Kashida. I put a reference there to this discussion anyway. – Shahryar Dec 11 '19 at 08:56
  • @UlrikeFischer, I added an edit to explain more. – Shahryar Dec 11 '19 at 08:56
  • 1
    @Shahryar yes that one – David Carlisle Dec 11 '19 at 09:03
  • @HenriMenke, thanks for the link. But I am not sure if the "Visual METAFONT" can help in our case (if I could understand the slides correctly). The length of a kashida depends on the paragraph parameters and not just the series of letter. So, applying kashida should be something in luatex or harfbuzz but not the font internal. – Shahryar Dec 11 '19 at 09:08
  • 1
    Improving searching should be possible, one could try to add an empty /ActualText in the pdf the luaotfload code does this already for a number of glyphs (but I would have expected the pdf reader to know that it should ignore the glyph). – Ulrike Fischer Dec 11 '19 at 09:26
  • @Thanks for mentioning /ActualText. It can probably solve the problem. Besides pdf readers, it is search engines which should find words correctly (which I guess /ActualText would fix it at the same time). – Shahryar Dec 11 '19 at 10:35
  • 1
    Indeed, I've studied the possibility of adding some support for kashida in babel, but my first experiments were quite unsatisfactory (in particular, the \hrule hack), and I haven't investigated any further. – Javier Bezos Dec 11 '19 at 14:21
  • @JavierBezos, yes \hrule hack creates unsatisfactory results (I remember that once I have tried to stretch the kashida glyph itself, but do not remember if it created different result, probably not). Any plan for further investigation in future? – Shahryar Dec 11 '19 at 15:00
  • 1
    @Shahryar Very likely, if nobody tries before :-). – Javier Bezos Dec 11 '19 at 16:30
  • 1
    Once variable fonts are supported, there’s a SIL-licensed font which looks suitable for experimenting with kashida: https://github.com/aminabedi68/Estedad – Thérèse Dec 14 '19 at 20:12
  • 1
    @Shahryar Well, I've finally decided to tackle the task and there wiil be very likely at least some basic support in luatex very soon. I have my doubts that with xetex we can go much further than, eg, texnegar. See an example here: https://twitter.com/javier_bezos/status/1387742677731524609 . – Javier Bezos May 03 '21 at 07:38
  • 1
    @JavierBezos, that is a good news. Since 2019, variable fonts became more common, most of them with support for Kashida. Such as:

    https://github.com/rastikerdar/vazir-font

    https://fontiran.com/%d9%81%d9%88%d9%86%d8%aa-%d8%af%d8%a7%d9%86%d8%a7-%d8%ad%d8%b1%d9%81%d9%87%e2%80%8c%d8%a7%db%8c/

    However, I could not see Tex implementations based on that. Solutions such as TexNegar do not utilize this feature but rely some older work-around which is limited to specific fonts, with serious problems.

    Similarly, I think Luatex is the one to invest in.

    – Shahryar May 03 '21 at 21:24
  • 1
    @Shahryar I'll take a look at the font (thank you for the pointer!). At the moment, I am focusing on the jalt alternatives and the insertion of kashida. – Javier Bezos May 04 '21 at 05:51
  • 1
    @JavierBezos Good!

    I provided two links, one seems missing in the above:

    https://fontiran.com/%d9%81%d9%88%d9%86%d8%aa-%d8%af%d8%a7%d9%86%d8%a7-%d8%ad%d8%b1%d9%81%d9%87%e2%80%8c%d8%a7%db%8c/

    – Shahryar May 04 '21 at 07:29

1 Answers1

3

You can use TeXNegar package.

From the User Documentation of the package:

The TEXNegar package implements kashida justification in LuaTeX and XeTeX and fixes known bugs in xepersian.

Tisha Shusho
  • 314
  • 1
  • 11