Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Going Crazy (How to Install a Font)

Going Crazy (How to Install a Font)

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialhelpworkspace
3 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    netx2003
    wrote on last edited by
    #1

    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.

    A R 2 Replies Last reply
    0
    • N netx2003

      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.

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      Is the problem something to do with the windows security?

      1 Reply Last reply
      0
      • N netx2003

        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.

        R Offline
        R Offline
        Roger Allen
        wrote on last edited by
        #3

        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...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups