Python 图像库 (PIL) 可以将文本渲染为图像——我不知道它是不准确,但我还没有完全测试过......
先前存在的问题的示例:
from PIL import Image
from PIL import ImageFont, ImageDraw
image = Image.new("RGBA", (288,432), (255,255,255))
usr_font = ImageFont.truetype("resources/HelveticaNeueLight.ttf", 25)
d_usr = ImageDraw.Draw(image)
d_usr.fontmode = "1" # this apparently sets (anti)aliasing. See link below.
d_usr.text((105,280), "MYTEXT",(0,0,0), font=usr_font)
也可以看看:
http://www.pythonware.com/products/pil/ http://www.pythonware.com/products/pil/
http://mail.python.org/pipermail/image-sig/2005-August/003497.html http://mail.python.org/pipermail/image-sig/2005-August/003497.html
Python 图像库 - 文本渲染 https://stackoverflow.com/questions/5414639/python-imaging-library-text-rendering