Writing a font viewer - getting font properties, loading ttf dynamically

I am trying to write a font viewer for TrueType / OpenType fonts with VB6 / VB5 code (under Windows).

this is surprisingly difficult:

1) in VB / winAPI, I haven't found how to extract the font name or font properties in general.

2) I can install the font (using the AddFontResource API function), but then it needs to be removed. However, although (AddFontResource "expects pathname , removing the font requires the name font , which I don't know.)

is there a way to use the ttf font not installed)?

Is there a way to extract font properties using vb6?

(I can write a program in wxPython, but I know even less about fonts in python than I do in VB)

+2


source to share


2 answers


You can use the FreeType library .



+1


source


It really is. I faced the same problem myself (see my question ). I ended up writing my own parser because I needed to determine if the font was corrupted or not. There is a function AddFontMemResourceEx

that:

When the function succeeds, the caller of that function can free the memory pointed to by pbFont because the system made its own copy of the memory. To remove installed fonts, call RemoveFontMemResourceEx. However, when the process exits, the system will unload the fonts, even if the process did not call RemoveFontMemResource.



Alternatively, you can use Font and Text Functions to get font metrics.

0


source







All Articles