Alec Bennett wrote: > I'm trying to access the following function from the Windows API: > > http://msdn.microsoft.com/en-us/library/dd144885(VS.85).aspx > > I'm sure I'm drastically over simplifying, but I'm testing it like this: > > import win32api > print win32api.GetFontData() > > This of course errors out with "AttributeError: function 'GetFontData' not > found". > > Does anyone have any tips on how I might access this function? I need to > resolve the font face name (for example, "Arial") as returned by wxPython, to > the Windows filename (for example, c:\windows\fonts\arial.ttf) as required by > the Image module, and it looks like GetFontData() from the Windows API is the > solution. >
Although it IS possible to find this information using the API, it is quite tedious. You'd need to have a DC, create an HFONT, select it into the DC, then run GetOutlineTextMetrics, which is not a Python-friendly API. You get back a long structure where some members include the offset to the strings you need. A much better solution is to search through the registry values in HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts. That maps each font name to its corresponding file name. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32