How do I find the postscript names for the installed fonts on Windows
I can get a list of the installed font families and available styles on Windows with this powershell
$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.
