Just as a bit of an introduction, this article refers to the wedding website I am making to manage the guests that are coming to my wedding. So far, the website has guests, it has locations (places where events for the wedding will occur) and it has pages to manage these entities. Also, by the power of Django, guests can already login and see a blank page. You may be wondering why anyone would want to login to view a blank page, and my answer is they wouldn't want to. So today I started researching how best to display the invitations. For the invitations I have a few requirements, they should have an image background, then there is a certain amount of static text in a certain font, and the name of the guest in a separate font. The names have to be added later and preferably by a script as I do not want to sit around for several hours and insert names into the invitations, file by file. Not that I do not appreciate my guests, but computers were invented for a reason!
Now, invitations usually have sexy fonts and I do not want my invitations to be any different. The fonts available on my computer are not very sexy at all and I did not think that Times New Roman was appropriate, so I went searching for beautiful True Type Fonts. After finding some that I liked, Urban Fonts has some good calligraphy fonts, I started looking into how to use these fonts and applying them to invitations.
I decided I would have a go at using python to generate invitation images for people to download, print or whatever. I decided to use the Python Imaging Library, this library allows you to manipulate image files and load and render text to images. The process would be to have a background image, render my static text onto it using one font, then take the list of guests and render their names in their individual invitation that would then be stored on the web server. The invitations are served to guests as part of the invitation site, so we do not want them regenerated each time a guest logs in to look at it. Because of this the invitations are all generated as a batch.
Now of course, when I did my first rendering everything went bad. The true type fonts kept getting clipped at the edges, “g” was missing its tail, “h” was missing its swirly top. After googling around a bit, I found fontforge, a truly glorious program that allows you to edit true type fonts. I tweaked the fonts I was working with to fit into their bounding boxes, resized them and fixed the character spacing to just how I like it. If anyone ever wants to do text rendering to images in python, I highly recommend the use of these two tools. In fact, these will be very important for the next Pyweek competition.
A friend of mine, screwtape. suggested that I should use inkscape instead of a python script to make the invitations. This would work by running the svg invitation file generated by inkscape through a script to insert peoples names then use inkscape to export the svg file as a png. There are some advantages to this method. One is that the image will be vector based right up until it gets converted to a png making editing it easy. The other is that the SVG is in a xml format, allowing me to edit the guests names using a script. The contrast to my script is that I start with building blocks, the background, the text and peoples names and generate a complete image from that.

Comments
I'm amused to know that
I'm amused to know that instead of drinking with us on a Saturday night you were at home writing this post.
Well, I do have to get this
Well, I do have to get this done soon, wedding is coming up :P
Also, I'm going to recommend
Also, I'm going to recommend you something else for your sexy font goodness. This is how sexy fonts are generally handled in the world of web design. It's called flash text replacement or sIFR.