开发者

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

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

it is surprisingly difficult:

1) in VB / winAPI, i did not find how to extract the font's name, or font properties in general.

2) i can install the font (using AddFontResource API function), but then have to uninstall it. However, while (AddFontResource" expects a pathname, removing the font requires the font's name which is unknown to me.

is there a way to use an non-installed font ttf) ?

is there a way to extract a f开发者_开发知识库ont's properties using vb6 ?

(I can write the program in wxPython but i know even less about fonts in python than with VB)


You could use the FreeType library.


It indeed is. I have faced the same problem myself (see my question). I ended up writing my own parser though because I needed to detect if the font was corrupt or not. There is a AddFontMemResourceEx function which:

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜