The standard Arabic rendering recipe corrupts Arabic on any modern renderer - now filed upstream

#2
by syamjithnk - opened

arabic_reshaper + python-bidi is the advice in almost every tutorial for drawing Arabic.
On a renderer that already does complex-text layout - Pillow linked against Raqm/HarfBuzz, which
is the default - it now corrupts the text, because shaping and the bidi reorder happen twice.

"welcome":

rendered
no preprocessing مرحبا بكم
reshape() + get_display() مكب ابحرم

5 strings x 3 fonts per path:

path no preprocessing with reshape + bidi
Pillow with Raqm 15/15 identical 0/15 - 14 broken, 1 recognisable
Pillow without Raqm 0/15 - 15 broken 0/15 - 9 recognisable, 6 still broken

Two things follow. With Raqm, the preprocessing takes a path that is 100% correct and breaks all
of it. Without Raqm it is a partial rescue, not a fix - 9 of 15 move from broken to merely
recognisable and 6 stay broken. A pass/fail score reports that second row as "works", which is
how the recipe keeps its reputation.

Detection is one line:

from PIL import features
needs_reshaping = not features.check("raqm")

Now filed upstream with the maintainer:
https://github.com/mpcabd/python-arabic-reshaper/issues/102

Scoring is shape-invariant IoU against a reference, normalised to the ink bounding box, graded in
three bands rather than pass/fail - the middle band is what surfaced the partial-rescue case.
All renders and per-item results are in this repo, CC BY 4.0.

syamjithnk changed discussion status to closed

Closing as a duplicate of #1, which covers the same finding. Please continue there.

Sign up or log in to comment