PDF renderer: Normalize unicode before printing text

This commit is contained in:
Raphael Michel
2022-11-10 13:53:15 +01:00
parent 655cfe0afd
commit dfedf09656

View File

@@ -40,6 +40,7 @@ import os
import re import re
import subprocess import subprocess
import tempfile import tempfile
import unicodedata
import uuid import uuid
from collections import OrderedDict from collections import OrderedDict
from functools import partial from functools import partial
@@ -860,6 +861,9 @@ class Renderer:
except: except:
logger.exception('Reshaping/Bidi fixes failed on string {}'.format(repr(text))) 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) p = Paragraph(text, style=style)
w, h = p.wrapOn(canvas, float(o['width']) * mm, 1000 * mm) w, h = p.wrapOn(canvas, float(o['width']) * mm, 1000 * mm)
# p_size = p.wrap(float(o['width']) * mm, 1000 * mm) # p_size = p.wrap(float(o['width']) * mm, 1000 * mm)