Search code examples
powershellfontsregistryopentype

OpenType fonts in the Windows Registry


I am writing a PowerShell script to install TrueType and OpenType fonts in Windows. The script is adding a registry entry in Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts and copies the font-file to C:\Windows\Fonts. If I don't do it like this and only copy the file to the font directory Windows automatically installs the font in the user space instead (C:\Users\UserName\AppData\Local\Microsoft\Windows\Fonts).

I can see that the few OpenType fonts that I have on my computer and that have been installed by Windows have a string name like "FontName (TrueType)" in the registry, even though they are OpenType fonts?? Wouldn't it make more sense if the name was "FontName (OpenType)"?

Is there a standard around this?


Solution

  • For purposes of getting a font registered and enumerated in the system, the strings used for entry names have no significance. An entry named "spam" would work just as well as "Arial Regular (TrueType)" or "Arial Regular (OpenType)". All that matters is uniqueness within that key.

    However, for maintenance of the registry — installation or removal of fonts, and migration during an upgrade or to a new system — there are parts of the OS that expect the entry names to be of a particular format. So, even if a font can be considered an OpenType font, you should use the template " (TrueType)" for the entry names.

    As noted by others in comments, the TrueType vs. OpenType distinction is fuzzy. Most fonts that might be considered TrueType fonts would qualify as OpenType fonts, but not all; in particular, some fonts for MacOS use extensions defined in Apple's TrueType Reference Manual but not in the OpenType spec. And the OpenType spec has several extensions not included in Apple's TrueType reference manual.

    But for your purposes, the TT vs. OT distinction isn't relevant. Always use "(TrueType)" in the registry.