Created
January 10, 2012 15:34
-
-
Save magikmw/1589637 to your computer and use it in GitHub Desktop.
ttf to png
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#USAGE: | |
#python TCODfont.py /path/to/font/font.ttf 12 | |
import Image, ImageFont, ImageDraw, sys | |
fontpath = sys.argv[1] | |
fontpoint = int(sys.argv[2]) | |
image = Image.new('RGB', [fontpoint*16, fontpoint*16]) | |
draw = ImageDraw.Draw(image) | |
font = ImageFont.truetype(fontpath, fontpoint) | |
i = 0 | |
for row in range(0, 16): | |
for col in range(0, 16): | |
xpos = fontpoint*col+1 | |
ypos = fontpoint*row | |
draw.text((xpos, ypos), chr(i), font=font) | |
i += 1 | |
image.save('tcod.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment