From acf1cf3792b3a219eba0fb8ba4390e33893b3f5e Mon Sep 17 00:00:00 2001 From: flex-oops <94053950+FullStraing@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:38:12 -0800 Subject: [PATCH] Warn against pre-processing text with arabic_reshaper and python-bidi when libraqm is available --- docs/reference/ImageDraw.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/reference/ImageDraw.rst b/docs/reference/ImageDraw.rst index f81bb7fac93..ff8039c4573 100644 --- a/docs/reference/ImageDraw.rst +++ b/docs/reference/ImageDraw.rst @@ -482,6 +482,20 @@ Methods .. versionadded:: 6.0.0 + .. note:: **Complex scripts.** When libraqm is available, Pillow + performs shaping and applies the bidirectional algorithm itself, so + do not pre-process text with ``arabic_reshaper`` and ``python-bidi`` + first: the text would be shaped and reordered twice, and the result + is incorrect. ``arabic_reshaper`` also drops diacritics. This + pre-processing is only needed on builds without libraqm, so check + ``PIL.features.check("raqm")`` at runtime, in the environment doing + the rendering, to decide whether it is needed:: + + from PIL import features + + if not features.check("raqm"): + text = get_display(arabic_reshaper.reshape(text)) + :param stroke_width: The width of the text stroke. .. versionadded:: 6.2.0