PIL question. having exactly same font on multiple platforms

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Aug 4 14:37:27 CEST 2011


Gelonida N wrote:

> I wondered what library would be appropriate and would yield the same
> result independent of the OS (assuming the versions of the python
> libraries are the same)
> Images should be pixel identical independent on the platform on which
> the image is created.

Short answer: you can't.

Long answer: you might, if you can find identical fonts (not just fonts with
the same name, but genuinely identical) for each platform, and find some
way of telling each platform's font rendering software to use identical
algorithms (e.g. kerning, hinting, scaling, sub-pixel rendering), and
adjust for any other differences between platforms (e.g. font sizes on
Windows tend to be larger than on Mac or Linux).

And when I say "you might", I mean it is theoretically possibly, but
practically speaking, you can't.

Even longer answer: you can, if you ignore the platform font renderer, and
use your own custom renderer; this is what (apparently) a number of
Linux/Unix applications like Abiword and xpdf do (with varying levels of
success). You still need to find identical fonts for each platform.
Possibly the simplest way to do this is to stick to old-fashioned bitmapped
fonts in fixed sizes, instead of Postscript or TrueType fonts -- assuming
you don't mind your application's output looking like it was produced on a
Macintosh in 1984.

More information here:

https://freddie.witherden.org/pages/font-rasterisation/
http://www.joelonsoftware.com/items/2007/06/12.html
http://www.codinghorror.com/blog/2007/06/whats-wrong-with-apples-font-rendering.html
http://jujusoft.com/?page_id=25


-- 
Steven




More information about the Python-list mailing list