[Image-SIG] PIL Fonts, TTF fonts, converting, rendering, how do I go about this?

A M Thomas am@virtueofthesmall.com
Thu, 04 Apr 2002 00:18:44 -0500


Hello,

I've been working with the Python Imaging Library (PIL) a bit, and my
goal is to make some nice gif images of text, antialiased to a
background color of my choosing, with the actual background transparant.

I seem to be stuck on the problem of getting my TrueType fonts converted
successfully into pil fonts.  I successfully converted one using a free
utility for windows called "ttf2bdf"; the output is a text-readable file
(I mention this because I've never worked with BDF fonts before).  My
understanding was that the "pilfont utility" to convert BDF fonts into
the special PIL font format.  I found the pilfont.py script, but it
gives errors when I run it (KeyError: c is one example - it seems to be
converting everything into lower case, then not handling that well - I
fixed that one, but got another error I'm not sure how to fix, and this
seems to be not a promising avenue).

So, can anyone please tell me if I'm missing something here?  Is there a
better way to make these PIL fonts?

I found a few places describing python modules that would handle TTF
font rendering directly, but the pages all seemed dated 1999 at the
latest, and the lack of information makes me think these were efforts
that didn't reach full fruition.  Is this an erroneous impression?

Or, for a "best possible for me" scenario, is anyone doing what I
described above (creating antialiased text from TTF fonts, converted or
not) that would be willing to share some code?

Many thanks,
Am