win32ui.CreateFont() question

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Fri Nov 21 08:48:17 EST 2003


I am rewriting an antique BASIC program in Python for a
customer.  The main feature of the program is printing a
work order for a particular assembly; the BASIC program
uses IBM OEM line-drawing characters.

The new program must reproduce the work order as closely as
possible but be able to print to brainless inkjet printers.
I found the MS Linedraw font online, and am able to print
the line-drawing characters with it under Windows XP but
the same code fails to work in Windows 98, printing 
international characters instead. 

I'm not sure what code to post from the application (the
printing code is a bit long to post), but if nobody has 
an easy answer I'll see what I can boil down.

I'm calling CreateFont using this function:

    LOGPIXELSY = 90

    def getfont(dc, name, size):
        scaley = dc.GetDeviceCaps(LOGPIXELSY) / 72.0
        return win32ui.CreateFont({
            "name": name,
            "height": int(1.0 * scaley * size),
        })

If there is a better/more correct way I'd be happy to
see it.

Also:  How do you know what font Windows actually chose?
The PyCFont returned by win32ui.CreateFont() does not have
any properties or methods as far as I can tell, so no way
to access the underlying MFC CFont object.

Chris Gonnerman -- chris.gonnerman at newcenturycomputers.net
http://newcenturycomputers.net






More information about the Python-list mailing list