From eea48af60a5f332055c259d6f5b11919a0263650 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 31 Jan 2023 17:11:47 +0100 Subject: [PATCH] PDF: Fix Arabic string rendering --- src/pretix/base/pdf.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pretix/base/pdf.py b/src/pretix/base/pdf.py index 2a0869c48d..cb7fdb3525 100644 --- a/src/pretix/base/pdf.py +++ b/src/pretix/base/pdf.py @@ -862,6 +862,10 @@ class Renderer: self._get_text_content(op, order, o) or "", ).replace("\n", "
\n").replace("-", "- ") + # reportlab does not support unicode combination characters + # It's important we do this before we use ArabicReshaper + text = unicodedata.normalize("NFKC", text) + # reportlab does not support RTL, ligature-heavy scripts like Arabic. Therefore, we use ArabicReshaper # to resolve all ligatures and python-bidi to switch RTL texts. try: @@ -869,9 +873,6 @@ class Renderer: except: logger.exception('Reshaping/Bidi fixes failed on string {}'.format(repr(text))) - # reportlab does not support unicode combination characters - text = unicodedata.normalize("NFKC", text) - p = Paragraph(text, style=style) w, h = p.wrapOn(canvas, float(o['width']) * mm, 1000 * mm) # p_size = p.wrap(float(o['width']) * mm, 1000 * mm)