How to add font to system, programmatically?

29 10 2008


Diablo
! It was my favorite game during my childhood. Chopping down monsters, bats… Wow!!! I love it. Every time when i start the program one thing that attracted me is its font.Later when I searched net, i found that there is a font named diablo. But what will happen if the font is not present in the system? The game screen will be wired? The application might be installing the font, if its not present in the system. But how to do it?


Well, You can use the api – AddFontResource(). You have to provide the path of font file to be added to system. Have a look at the code snippet.

// Path of font to be added.
CString csFontPath = _T( "C:\\Diablo.ttf" );

// Add font to system.
if( 0 == AddFontResource( csFontPath ))
{
   // Adding font to system failed.
}


Well, the latest version of diablo is Diablo III. Its superb! Have a look at it. 😉


Targeted Audience – Intermediate.

Advertisements