Issue
The function in question:
PIL.ImageDraw.Draw.text(xy, text, fill=None, font=None, anchor=None)
The issue is pretty standard... gibberish:
Right now, I'm running a string (utf-8) into the draw text function above, but it's giving all those weird characters. However, if I just print it, it shows the characters fine.
Should I pass a Unicode object instead?
Solution
This works correctly on Python 3.6.2 and 2.7.13 with pillow-4.2.1 (strings are default Unicode in Python 3.x). Chinese didn't display with the default font, but Arial MS Unicode worked.
#coding:utf8
from PIL import Image,ImageDraw,ImageFont
im = Image.new('1',(100,100))
draw = ImageDraw.Draw(im)
font = ImageFont.truetype(font='ARIALUNI.TTF',size=20)
draw.text((0,0),u'马克','white',font=font)
im.show()
Output:
Answered By - Mark Tolonen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.