libschrift icon indicating copy to clipboard operation
libschrift copied to clipboard

Support for RTL languages

Open deltabeard opened this issue 3 years ago • 3 comments

RTL languages, such as Persian, are rendered as though they are LTR text, and therefore appear disjointed as shown below.

Image showing issue with rendering RTL text

Are there any plans to add support for RTL languages?

Many thanks.

Persian test text

deltabeard avatar Aug 19 '20 13:08 deltabeard

Yes, RTL languages are something that I want to support, but I'm not sure when I'll get around to it.

I will have to do more research on how they are implemented in TrueType first. But, if they work the way I think they do, then there will be no changes to libschrift necessary - It is likely just sftdemo (and any other application that uses libschrift) that has to be changed.

Things get complicated though if an application wishes to support mixed LTR and RTL text (which is very likely). Then they will need an algorithm that swaps characters around until the entire text is completely LTR (or RTL). For Unicode, this "BiDi" algorithm is standardized. But just the reference implementation of that algorithm is two times as large as the entirety of libschrift...

By the way, thanks for the sample text.

tomolt avatar Aug 20 '20 10:08 tomolt

Thank you for your reply and for your great work so far. I'm personally not bothered about LTR and RTL being mixed within the same text. But I wonder if that issue applies to numbers in Persian, which are written LTR within text that is RTL, as shown below.

بیش از ۹۰۰۰ است

The sample text is the poem Bani Adam written by Iranian poet Saadi in 1258. I sourced the text from https://en.wikipedia.org/wiki/Bani_Adam :slightly_smiling_face:

deltabeard avatar Aug 20 '20 21:08 deltabeard

When you say disjoined, you mean that text shaping is missing right? Which instead really an RTL issue. RTL, without bidirectional text support, is simply solved by mirroring text without mirroring the glyphs (I think there are some glyphs you have to substitute for mirrored versions, such as brackets), but text shaping is more involved.

maandree avatar Aug 05 '21 17:08 maandree