How to install a Font programmatically (C#)

As you mentioned, you can launch other executables to install TrueType Fonts for you. I don’t know your specific use cases but I’ll run down the methods I know of and maybe one will be of use to you.

Windows has a built-in utility called fontview.exe, which you can invoke simply by calling Process.Start("Path\to\file.ttf") on any valid TrueType Font… assuming default file associations. This is akin to launching it manually from Windows Explorer. The advantage here is it’s really trivial, but it still requires user interaction per font to install. As far as I know there is no way to invoke the “Install” portion of this process as an argument, but even if there was you’d still have to elevate permissions and battle UAC.

The more intriguing option is a utility called FontReg that replaces the deprecated fontinst.exe that was included on older versions of Windows. FontReg enables you to programatically install an entire directory of Fonts by invoking the executable with the /copy switch:

    var info = new ProcessStartInfo()
        {
            FileName = "Path\to\FontReg.exe",
            Arguments = "/copy",
            UseShellExecute = false,
            WindowStyle = ProcessWindowStyle.Hidden

        };

   Process.Start(info);

Note that the Fonts have to be in the root of wherever FontReg.exe is located. You’ll also have to have administrator privileges. If you need your Font installations to be completely transparent, I would suggest launching your application with elevated permissions and approve of the UAC up front, that way when you spawn your child processes you wont need user approval Permissions stuff

Leave a Comment