[Python] gdmodule true type font size

Eric Brunel eric.brunel at pragmadev.com
Wed Sep 17 10:11:05 EDT 2003


John Hunter wrote:
>>>>>>"Chris" == Chris Gonnerman <chris.gonnerman at newcenturycomputers.net> writes:
>>>>>
> 
>     Chris> No.  The underlying GD library assumes 1 point is exactly 1
>     Chris> pixel.  Font metrics are pretty fuzzy, so your mileage may
>     Chris> vary slightly especially with script fonts.
> 
> That helps thanks ...
> 
>     Chris> You've got me here.  Perhaps if I knew what you were trying
>     Chris> to accomplish at a bit higher level, I might be able to
>     Chris> make a suggestion.
> 
> That's OK, I think I have this figured out.  The one point/one pixel
> info was enough to speed me on my way.

I just found a mail I sent a few time ago to Thomas Boutell, who created the gd 
library, and it seems there is a constant named GD_RESOLUTION in file gd.h that 
may help you to solve your problem (if you haven't already solved it). In former 
versions of gd, this constant was set by default to 96, which means that a pixel 
was not 1/72 inch, but 1/96 inch. Since font size units are supposed to be 
printer points (= 1/72 inch), setting a font size 12 in gd results in an actual 
size 12 * 96 / 72 = 16 pixels, and not 12 as you would expect.

This problem happened in gd 1.8, and I haven't tried the new version. If it 
wasn't corrected, changing this constant to 72 may help to get the size you want.

HTH
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com





More information about the Python-list mailing list