[Image-SIG] ImageDraw questions.

Fredrik Lundh fredrik at pythonware.com
Sun Mar 30 14:54:56 CEST 2008


KwangYul Seo wrote:

> I draw fonts using ImageFont module. I have two questions on ImageDraw 
> module.
> 
> 1. What is the unit of font size?
> 
> ImageFont.trutype(file, size) can specify the font size as its second 
> argument. I specified font size 10, but the output text seems to be 
> smaller than 10.

The relation between the font size and the text height is determined by 
the font designer; usually, the given size is the *smallest* line height 
you will want to use for the font you get back.  See Ned's post for a 
link to a more complete discussion.

 > 2. What is the best way to get a list of fonts which can be passed to 
 > ImageFont.truetype(file, size)? Certainly, I can scan Windows system
 > fonts under C:/WINDOWS/Fonts, but it does not look like a portable
 > way.

There's no code for this in current PIL releases.

The following module might help; it's a work-in-progress for AggDraw, 
but should be fairly easy to adapt to both PIL and your requirements:

     http://svn.effbot.org/public/stuff/sandbox/agglib/aggfont.py

</F>



More information about the Image-SIG mailing list