Here's a working implementation of S. Mark's answer, which unloads the characters "a" into "z" in black at the correct PNG size:
import Image, ImageFont, ImageDraw
font = ImageFont.truetype("font.ttf", 16)
im = Image.new("RGBA", (16, 16))
draw = ImageDraw.Draw(im)
for code in range(ord('a'), ord('z') + 1):
w, h = draw.textsize(chr(code), font=font)
im = Image.new("RGBA", (w, h))
draw = ImageDraw.Draw(im)
draw.text((-2, 0), chr(code), font=font, fill="#000000")
im.save(chr(code) + ".png")
source
share