How to install a font into system with API?
Posted on 2003-11-12 22:39:53 by optimus
You need to copy the font file to your Fonts folder then list the font file in the registry:


jmp @F
SubKey db "Software\Microsoft\WindowsNT\CurrentVersion\Fonts",0
szFontFile db "ARIAL.TTF",0
szFontName db "Arial (TrueType)",0

invoke StrLen, OFFSET szFontFile
invoke RegSetValueEx, RegKey, OFFSET szFontName, NULL, REG_SZ, OFFSET szFontFile,eax
invoke RegCloseKey, RegKey

If you are just looking to use it for the duration of your program and not permanently add it to the system font table then you have only to use AddFontResource

invoke AddFontResource, OFFSET szFontFile
Posted on 2003-11-12 23:06:51 by donkey
Thanks! Does the first method need a reboot to take effect?
Posted on 2003-11-12 23:21:17 by optimus
I have to admit that I have never used it, I saw it on a web page somewhere a while back but I can't remember where, just remembered the basic way it is done. But I think that like most of these types of functions no reboot is required.
Posted on 2003-11-12 23:26:26 by donkey
A little off topci, but I wrote an app a while back that uses an unregistered ttf font in an application, by storing it within the resource section and dumping it to a temp directory for use while the app is running. I dont know if it would be usefull to you or not, but the link is here:
Posted on 2003-11-13 00:47:29 by NaN
Complete App, tested W95 to W2K. I will guess that it will work with XP & Up. This code includes all system notifications.

You must provide the font to load, when you build the install file. ( It's embedded in the resources. )

The App was coded by me with some help from here. You folks know who you are.
It was coded as a updating font installer, so it removes a previous version, if it exists. No re-boot required, unless font is in use.

Regards, P1
Posted on 2003-11-13 14:38:40 by Pone