I'm using PIT to put Kurdish(sorani, arabic-like) text on an image, but the text on the image is separated from each other. Does anyone knows how to solve this problem?
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")
PIL can't handle shaping Arabic-like fonts, (unless they fixed it recently). I've seen one library, like this reshaper library, which will combine characters correctly. Other solutions include using pango or pycairo to deal with the font, see this discussion.