views:

61

answers:

1

I'm making a wxPython app, and I want to use some non-standard font that I have on file. How do I do this?

A: 

The Win32 API you need is called AddFontResource (you'll also want to use RemoveFontResource when you're done with a font). I haven't been able to find a python wrapper for this function, so you'll need to use ctypes or equivalent to access the API directly. Once the font has been added, it should be accessible in the usual way (note that it will be accessible to all applications).

There's an SO thread that suggests using a FreeType library wrapper (ft2) but this seems like overkill (unless you have some other need for it) and the wrapper is marked as beta.

jdigital
I was hoping for a cross-platform way. I thought this would be one of the things that a GUI framework is supposed to do...
cool-RR
Also, what happens if the program crashes before it calls `RemoveFontResource`?
cool-RR