Installing Fonts Programmatically on Windows
Working on a project, I came across the need to install a font on a machine. Now, manually, you can just right click on the font->install. Or I am pretty sure you can just copy into %windir%\fonts\ and it then it works, but it might not be usable until you reboot, I am not a font expert here so don’t quote me, but just from what I have been reading in the forums.
Now, to install a font programmatically, you can just copy it into the folder, but what if you want it usable right away? um… Well, some people say there are some reg keys you need to run, etc. But I came across another very undocumented app that Microsoft has: fontinst.exe
You can just call this program and pass in an .inf file as parameter and it will install the font for you.
The inf file is formatted like:
[fonts]
My Font Name.TTF
now, to call it, you can run “fontinst.exe /F MyFontName.inf” (if you saved the file as MyFontName.inf)
C++ Code:
ShellExecute( NULL, “open”, C:\\MyPath\\fontinst.exe”, ” /F MyFont.inf”,C:\\MyPath\\”, SW_HIDE );
And it should install your font!
Note: I think you can do multiple fonts in one .inf file, I didn’t try it because I didn’t need to install more than one at a time, but I read on the forums and such that it is possible.
Simlar Posts
- First-chance exception at 0×7c812a5b in
: Microsoft C++ exception: CError at memory location - C++ - Release Your Buffers
- Windows Live Writer - API Open (not really) - I Want To Download Existing Posts
- SQL: Moving log files for an existing database to another drive
- SQL Server: sp_add_job - parameter passing

September 28th, 2007 at 2:31 pm
I always just use AddFontResource — the only time the fonts I use are needed are when my application is running. But this way, I don’t clutter up the system font table with my own fonts (I remove font when the app closes).
The other trick is to use AddFontResource to make it available, and then update the registry entry for it manually.
http://support.microsoft.com/kb/102960/en-us
http://msdn2.microsoft.com/en-us/library/ms534231.aspx
September 28th, 2007 at 2:34 pm
that is good to know, yeah this will be the one stop shop font post :) - I didnt know about AddFontResource, but yeah, I need my fonts to be on the machine foreva! :)
October 3rd, 2007 at 7:16 am
hmm…
i thought you just had some one-word magic command you plugged into that application to make the fonts magically install.
=}