Going Crazy (How to Install a Font)
-
Hello, I am writing an small setup program and I need to install some fonts. I had look in MSDN and in many other places, but I can’t find the solution. AddFontResource works but only on the current session after a reboot the font is gone. I also tried CreateScalableFontResource with AddFontResource but I can’t get it to work. I copy the ttf font file to the windows fonts folder and it does not work. Here is a sample function:
//sFontFileName = Is the name of the font file Ex: arial.ttf will be arial //sFontLocation = Is the current location of the ttf file Ex: D:\setup\fonts\ //GetWindowsFolder() = return the windows folder Ex: c:\windows\ void InstallFont(CString sFontFileName, CString sFontLocation){ CString sFontResource(GetWindowsFolder() + sFontFileName + ".fot"); CString sWinFonts(GetWindowsFolder() + "Fonts\\" + sFontFileName + ".ttf"); ::CopyFile(sFontLocation + sFontFileName + ".ttf", sWinFonts, TRUE); CreateScalableFontResource(0, sFontResource, sWinFonts, NULL); AddFontResource( sFontFileName + ".fot" ); }
If you have any ideas please help. An example will be perfect. Thanks. -
Hello, I am writing an small setup program and I need to install some fonts. I had look in MSDN and in many other places, but I can’t find the solution. AddFontResource works but only on the current session after a reboot the font is gone. I also tried CreateScalableFontResource with AddFontResource but I can’t get it to work. I copy the ttf font file to the windows fonts folder and it does not work. Here is a sample function:
//sFontFileName = Is the name of the font file Ex: arial.ttf will be arial //sFontLocation = Is the current location of the ttf file Ex: D:\setup\fonts\ //GetWindowsFolder() = return the windows folder Ex: c:\windows\ void InstallFont(CString sFontFileName, CString sFontLocation){ CString sFontResource(GetWindowsFolder() + sFontFileName + ".fot"); CString sWinFonts(GetWindowsFolder() + "Fonts\\" + sFontFileName + ".ttf"); ::CopyFile(sFontLocation + sFontFileName + ".ttf", sWinFonts, TRUE); CreateScalableFontResource(0, sFontResource, sWinFonts, NULL); AddFontResource( sFontFileName + ".fot" ); }
If you have any ideas please help. An example will be perfect. Thanks. -
Hello, I am writing an small setup program and I need to install some fonts. I had look in MSDN and in many other places, but I can’t find the solution. AddFontResource works but only on the current session after a reboot the font is gone. I also tried CreateScalableFontResource with AddFontResource but I can’t get it to work. I copy the ttf font file to the windows fonts folder and it does not work. Here is a sample function:
//sFontFileName = Is the name of the font file Ex: arial.ttf will be arial //sFontLocation = Is the current location of the ttf file Ex: D:\setup\fonts\ //GetWindowsFolder() = return the windows folder Ex: c:\windows\ void InstallFont(CString sFontFileName, CString sFontLocation){ CString sFontResource(GetWindowsFolder() + sFontFileName + ".fot"); CString sWinFonts(GetWindowsFolder() + "Fonts\\" + sFontFileName + ".ttf"); ::CopyFile(sFontLocation + sFontFileName + ".ttf", sWinFonts, TRUE); CreateScalableFontResource(0, sFontResource, sWinFonts, NULL); AddFontResource( sFontFileName + ".fot" ); }
If you have any ideas please help. An example will be perfect. Thanks.We have had the same problem. Just copying the .ttf into the fonts directory is not enough. You also need to add some registry keys settings to get teh font to work correctly. Try copying in the font, use word etc to use it, which sometimes gets the font working initially. Then search the registry for the fonts filename, and hopefully that will return the reg keys you need to add, to get the font registering correctly when you first add the font. Roger Allen - Sonork 100.10016 Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...