Created
March 5, 2009 11:57
-
-
Save mrchrisadams/74326 to your computer and use it in GitHub Desktop.
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/env python | |
# encoding: utf-8 | |
""" | |
makewidget.py | |
Created by Chris Adams on 2009-03-03. | |
""" | |
from PIL import Image, ImageFont, ImageDraw | |
import sys | |
import os | |
def main(): | |
# open image to serve as background | |
pic = Image.open('blank_badge.png') | |
# set font with to convert Truetype file: | |
font = ImageFont.truetype("DIN-Bold.ttf", 36) | |
# convenience variable | |
textcopy = ImageDraw.Draw(pic) | |
# add fontmode should turn anti aliasing on. | |
textcopy.fontmode="0" | |
# start adding copy line by line to simulate | |
# line wrapping | |
textcopy.text((20, 25), "Ugly", font=font, fill=50) | |
textcopy.text((20, 85), "Aliasing", font=font, fill=55) | |
textcopy.text((20, 145), "Fixed?", font=font, fill=59) | |
# finally display image and save locally | |
pic.save('PIL-generated-fontmode.png') | |
pic.show() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment