6

我有python代码。"کم" 是一个字符串,由两个字母 ک 和 م 组成。但它们在阿拉伯语中组合在一起。我将这个词赋予 PIL 库函数。但它是两个字母分别保存图像。我怎样才能将它们结合起来。?

data2= "کم"    
draw.text(((W-w)/2,(H-h)/2),data2,(0,0,0),font=font)
draw = ImageDraw.Draw(img)
img.save("abc"+".png")

输出:即 ک 和 م 。

4

1 回答 1

5

您可以使用 python_arabic_reshaper 库来正确编写文本。这是该库的github存储库。

安装库:

pip install --upgrade arabic-reshaper

然后像这样导入它:

import arabic_reshaper

然后你可以像这样使用它:

text_to_be_reshaped = 'اللغة العربية رائعة'
reshaped_text = arabic_reshaper.reshape(text_to_be_reshaped)
于 2018-01-06T13:45:01.840 回答