Skip to content

Warn against pre-processing text with arabic_reshaper and python-bidi when libraqm is available - #10576

Closed
FullStraing wants to merge 1 commit into
python-pillow:mainfrom
FullStraing:docs/raqm-arabic-reshaper-warning
Closed

FullStraing wants to merge 1 commit into
python-pillow:mainfrom
FullStraing:docs/raqm-arabic-reshaper-warning

Conversation

@FullStraing

Copy link
Copy Markdown

Fixes #9907

Changes proposed in this pull request:

  • Add a note to ImageDraw.text() warning that pre-processing text with arabic_reshaper and python-bidi corrupts it on builds with libraqm, since Pillow already performs shaping and applies the bidirectional algorithm itself. The note includes the PIL.features.check("raqm") check to decide at runtime whether the pre-processing is needed, and mentions that arabic_reshaper drops diacritics.

Verified against the reproducer in #9907 on a Raqm build (Pillow 10.2.0, raqm 0.10.1): the recipe shortens "الإمارات" from 8 to 7 codepoints, drops all 4 diacritics from 'مَرْحَبًا', and renders differently from the plain text (4,202 differing pixels); undoing one bidi pass restores the plain rendering exactly. Docs build passes with no warnings on the changed file.

@radarhere

Copy link
Copy Markdown
Member

#9925 has already been created by the author of the issue. Do you think that your suggestion has anything to offer beyond that PR?

@FullStraing

Copy link
Copy Markdown
Author

Thanks for pointing to #9925 — I compared the two. The core warning is the same, but this PR adds a few things #9925 doesn't have:

Happy to fold the diacritics note and the call-site placement into #9925 instead, or to close this one if you'd rather keep a single PR — whichever you prefer.

@radarhere

Copy link
Copy Markdown
Member

Would you mind closing this, and creating a PR in the fork of that PR?

@FullStraing

Copy link
Copy Markdown
Author

I tried to do this, but I can't rebase onto #9925's branch from the web UI: #9925 branched from main on Sep 2, and a branch built on current main shows a 357-file diff against it, so a PR from there would be wrong. The additions are ready on my fork (FullStraing/Pillow, branch docs/raqm-additions-for-9925) if that's useful, but I can't open a clean PR against #9925's fork without git access to rebase. Would you prefer I instead open a small separate PR to main with just the ImageDraw.text() note, or should Syamjith-NK pick the note up into #9925?

@FullStraing

Copy link
Copy Markdown
Author

Closing this as requested — the additions are now proposed against the branch of #9925 in Syamjith-NK#2. Thanks!

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

Successfully merging this pull request may close these issues.

Warn that pre-applying arabic_reshaper + python-bidi corrupts text on a Raqm build

2 participants