Skip to main content
stib
Inspiring
August 19, 2019
Question

How do I find the postscript names for the installed fonts on Windows

  • August 19, 2019
  • 3 replies
  • 4114 views

I can get a list of the installed font families and available styles on Windows with this powershell

$folder = "$env:Windir\fonts\";

$objShell = New-Object -ComObject Shell.Application;

$attrList = @();

$details = @{ name = 0; style = 1;};

$objFolder = $objShell.namespace($folder);

foreach($file in $objFolder.items()){ $name = $objFolder.getDetailsOf($file, $details.name);

   $style = ($objFolder.getDetailsOf($file, $details.style)).split(";").trim();

   $attrList += ( @{name = $name; style = $style; });

};

set-content "$env:temp\fontlist.json" (ConvertTo-Json($attrList))

That creates a JSON file that lookjs like:

   {

        "style":  [

                      "Regular",

                      "Bold",

                      "Bold Italic",

                      "Italic"

                  ],

        "name":  "Trebuchet MS"

    },

    {

        "style":  [

                      "Regular",

                      "Bold",

                      "Bold Italic",

                      "Italic"

                  ],

        "name":  "Verdana"

    },

    {

        "style":  [

                      "Regular"

                  ],

        "name":  "Webdings Regular"

    },

    {

        "style":  [

                      "Regular"

                  ],

        "name":  "Wingdings Regular"

    },

    {

        "style":  [

                      "Regular",

                      "Light",

                      "Medium",

                      "Bold"

                  ],

        "name":  "Yu Gothic"

    }

...

I can create or get a textDocument and set its font to, say "Yu Gothic" like so:

var textDoc = new TextDocument("Foo")

textDoc.font = "Yu Gothic"

However that seems to work only for regular fontstyles. Attempting to set it to Yu Gothic Bold using

var textDoc = new TextDocument("Foo")

textDoc.font = "Yu Gothic-Bold"

Doesn't work and the default font is substituted. And of course textDoc.fontStyle is read-only. I mean why would anyone want to change the style of a font?

To change it to bold I have to use this:

var textDoc = new TextDocument("Foo")

textDoc.font = "YuGothic-Bold"

This wouldn't be such a problem if all I had to do was remove internal spaces from the font names and add the style with a hyphen at the end, but it doesn't always work. Time New Roman Bold is called "TimesNewRomanPS-BoldMT". This is apparently its Postscript name.

So my question is how do I find the postscript name for all available fonts on Windows using powershell, cmd or whatever so that I can get a list of installed fonts in my script. Really @Adobe this shouldn't be so hard.

This topic has been closed for replies.

3 replies

Adobe Employee
November 26, 2023

In case you are STILL interested, it is now possible to retrieve information about installed fonts via Scripting using the new (this year) app.fonts API.

 

See https://ae-scripting.docsforadobe.dev/other/fontsobject.html

 

Douglas Waterfall

After Effects Engineering

Tomas B. aka Tom10
Inspiring
August 21, 2019

There are a lot of inconsistencies, especially for fonts from the web/free resources.

My best bet would be to limit fonts used to the degree where their names are consistent and proven to be so. You will notice, that there are some rules, where gaps are treated as CamelCases, and styles separated by dash. It would be easy, if it wouldn't be difficult. Even for limited fonts taken from a single market (think it like Google Fonts), there are families, which 'Regular' won't come as dashed separate

stib
stibAuthor
Inspiring
August 20, 2019

Looks like automating anything to do with text is out of the question on Windows, huh.