How do I install a font through code?

HarvestR
02-13-2004, 12:11 PM
As pointed out by Optikal, this snippet of code warrented posting in the Code Library.

Here is my (cleaned and commented) code for adding a Font to Windows so i can be used immediately by all applications.

In the ZIP :

- Add_Fonts.vbp and Add_Fonts.vbw (project files)
- modAddFont.bas (the AddFont function fully documented)
- Form1.frm (it just shows how to call the function)
- bladrmf_.ttf (a sample font to let you try the AddFont() function)

Sorry for possible mistakes in the comments, English isn't my natural language.

Friendly,

HarvestR

HarvestR
06-13-2005, 11:24 AM
Here is a fix for my snippet for "How do I install a font through code?" in the Code Library.

I have found 2 little bugs in my code that I fixed:

First bug: New added fonts isn't listed until next reboot for NT based OS, because the registry key that holds fonts names is different in Windows 9x/Me and in Windows NT/2000/XP/2003.

Second bug: I added the full path to the fontfile in the registry, but only the filename is required. Using the full path works, anyway, but let's do it the way it has to...

I have updated my snippet so it is available for download.



Note to 00100b : Thanks for updated the code library with this fix ;)

HarvestR
07-05-2005, 11:50 PM
Hello 00100b

You updated my snippet for "How do I install a font through code?" to the Code Library a few weeks ago. Today an user reported me 1 little bug in my code :

DarthDemo: «The ParseKey() function is missing in the code (used for registry access).»

I have now fixed this (in fact two functions were missing).

Would you mind to update the Code Library with this last version ?

Thanks

HarvestR

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum