RTL语言未在reportlab的表中正确显示

2024-10-05 10:18:09 发布

您现在位置:Python中文网/ 问答频道 /正文

尽管使用drawCentredString正确显示阿拉伯文,但我无法在表中正确显示阿拉伯文

下面是一个例子:

from arabic_reshaper import reshape
from bidi.algorithm import get_display


def arabic(text):
    return get_display(reshape(text))
# This works
_canvas.setFont("NotoNaskhArabic-Regular", 24)
_canvas.drawCentredString(x=A4[0] / 2 - 10, y=760, text=arabic("نص عربي"))
# But this doesn't work
_canvas.setFont("NotoNaskhArabic-Regular", 18)
_head = Table([ [arabic("نص عربي")] ])
_head.wrapOn(_canvas, 0, 0)
_head.drawOn(_canvas, 10, 700)

渲染后

Python Reportlab Arabic bug


Tags: textfromimportgetdisplayhead例子canvas

热门问题