• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Engaged ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

3.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 21, 2019 Aug 21, 2019

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 26, 2023 Nov 26, 2023

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines