Cross platform TTF font render from Python [was: Load TTF from pycairounder Windows]

L

Laszlo Nagy

Hi All,

I need to render antialiased PNG images using TTF font files and UTF-8
text. It needs to be available at least on Linux and Windows. This is
what I have tried:

#1. PIL - it has some problems and I cannot use it. Specifically, the
ImageFont.getsize() returns bad value for some fonts, and there are some
TTF fonts that are rendered incorrectly (UTF-8)

#2. pycairo - very sophisticated, nice features, knows and does
everything correctly. However, has no native support for libfreetype. I
could write an extension in C and use it from Linux. Not available on
windows.

#3. gdmodule - I tried to install in under windows without success. No
binary installer available.

#4. pygame - documentation looks great, it is cross platform. But the
first example program I had tried has been terminated, printing out
memory dump and complaining about double freeing some memory location.

What other options do we have?

Thanks,

Laszlo
 
D

David Boddie

I need to render antialiased PNG images using TTF font files and UTF-8
text. It needs to be available at least on Linux and Windows. This is
what I have tried:
[...]

#4. pygame - documentation looks great, it is cross platform. But the
first example program I had tried has been terminated, printing out
memory dump and complaining about double freeing some memory location.

I'm surprised this doesn't work. I've seen games that are distributed
with TrueType fonts, so I would expect them to work, or people would
probably say something. :)
What other options do we have?

PyQt4 can render Unicode text to all sorts of paint devices, and it supports
TrueType fonts, too. You basically do all the painting via a single API:

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qpainter.html

Here's a quick example of how it could be done:

http://www.diotavelli.net/PyQtWiki/Paint on an image

All the relevant stuff happens in the updateImage() method.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top