I'm making a wxPython app, and I want to use s开发者_StackOverflow中文版ome non-standard font that I have on file. How do I do this?
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.
精彩评论