将库尔德文本(从右到左)添加到图像将返回分隔字符串

2024-07-06 23:20:20 发布

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

我使用PIT将库尔德语(sorani,类似阿拉伯语)文本放在图像上,但是图像上的文本是相互分离的。有人知道怎么解决这个问题吗?在

font_size = 100
img = Image.open("cute cat.jpg")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("./KGoran.ttf", font_size, encoding="unic")

text = "ڕۆژتان باش ئازیزان"
reversed_text = reversed(text)

fill = (0,0,0)
font = font

string_text = ""
for i in reversed_text:
    string_text += i

draw.text((0, 0), string_text, fill, font)
img.save("added text to image.jpg")

Tags: text图像image文本imgsizestringopen