I use PIL to draw text on an image.
I did, as in this example, the center / middle alignment text with PIL? but it worked, however, when the text phrase changes lines, they are not aligned.
The font is Verdana. Where could the problem be?
Displays 5 pixels correctly on the right side.
colour = 'white' text = 'Attack Speed 3.7' font = ImageFont.truetype("static/fonts/verdana.ttf", 10) draw = ImageDraw.Draw(base) w, h = draw.textsize(text) draw.text((width - 5 - w, 110), text, colour,font=font)
This is not so, about half of the words are outside the image area:
colour = 'white' text = 'One-hand hammer' font = ImageFont.truetype("static/fonts/verdana.ttf", 10) draw = ImageDraw.Draw(base) w, h = draw.textsize(text) draw.text((width - 5 - w, 95), text, colour,font=font)
source share