[python-win32] Fonts behaving differently - The plot thickens a bit

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Mar 6 05:07:37 CET 2011

I think I've narrowed down what's going on with the font
sizes a bit more. It has to do with the interperetation
of the nHeight parameter to CreateFont.

It appears that you can specify the height using either
a positive or negative number. One is taken to include
the font's internal leading, and the other isn't.

What seems to have happened is that somewhere between
builds 212 and 216 of pywin32, the behaviour of these
two cases has *swapped over*.

In my 2.x installation, which is using either 212 or
213 (I'm not exactly sure which at the moment) if I
ask for "Tahoma" with height +11 it comes out with
ascent = 11, descent = 2; whereas height -11 gives
ascent = 9, descent = 2.

But under 3.x with build 216, it's the other way around:
height +11 gives ascent = 9, -11 gives ascent = 11.

If I'm interpreting the MS docs correctly, then the new
behaviour is correct and the old one is wrong. Was there
a bug relating to this fixed at some point?

Also, is there a version number somewhere in pywin32 that
I can check at run time to work around this?


More information about the python-win32 mailing list