Python 2.7 Python PIL每个字符的宽度相同

Python 2.7 Python PIL每个字符的宽度相同,python-2.7,python-imaging-library,Python 2.7,Python Imaging Library,我试图通过使用python的PIL包在图片上绘制一些文本。有没有一种方法可以让我画出相同宽度的每个字符 谢谢 经过一段时间的思考,我得到了这个结论,下面的一段是我使用的: for num, (text, color) in enumerate(wrap): if num==12: current_h=0 if num<12: sw=0 else: sw=MAX_W/

我试图通过使用python的PIL包在图片上绘制一些文本。有没有一种方法可以让我画出相同宽度的每个字符


谢谢

经过一段时间的思考,我得到了这个结论,下面的一段是我使用的:

   for num, (text, color) in enumerate(wrap):
        if num==12:
            current_h=0
        if num<12:
            sw=0
        else:
            sw=MAX_W/2
        w,h=d.textsize(text.decode('gbk'), font=f)
        print list(text)
        for char in list(text):
            d.text((10+sw, current_h), char.decode('gbk'), font = f, fill = color)
            sw+=10
        current_h+=h
        print w,h
枚举(换行)中的num(文本、颜色)的
:
如果num==12:
电流h=0

如果是恒定字符宽度的numUse字体。