I had a similar issue, but for Photoshop. So I wrote the code below. It outputs a CSV of all the fonts installed in your system with their filename, Windows name and Postscript name.
You need to have Photoshop and Python installed to run it. Before running it, also keep a Photoshop window open so it can grab the list of fonts from there.
Shortname function was from here - https://gist.github.com/pklaus/dce37521579513c574d0
# This program lists all installed fonts on the computer with their font file name, Windows name and Postscript name.
import os
from fontTools import ttLib
from win32com.client import GetActiveObject
import pandas as pd
FONT_SPECIFIER_NAME_ID = 4
FONT_SPECIFIER_FAMILY_ID = 1
list = []
app = GetActiveObject("Photoshop.Application") # Get instance of open Photoshop window
df = pd.DataFrame(columns=['Font File Name', 'Windows Name', 'Postscript Name'])
def shortName(font):
"""Get the short name from the font's names table"""
name = ""
family = ""
for record in font['name'].names:
if b'\x00' in record.string:
name_str = record.string.decode('utf-16-be')
else:
name_str = record.string.decode('utf-8')
if record.nameID == FONT_SPECIFIER_NAME_ID and not name:
name = name_str
elif record.nameID == FONT_SPECIFIER_FAMILY_ID and not family:
family = name_str
if name and family: break
return name, family
def getPostScriptName(winName):
for i in range(0, len(app.fonts)):
if(app.fonts[i].name == winName):
return app.fonts[i].postScriptName
x = 0
for file in os.listdir(r'C:\Windows\Fonts'):
if (file.endswith(".ttf") or file.endswith(".otf")):
# list.append(file)
try:
fontfile = file
file = "C:\\Windows\\Fonts\\" + file
tt = ttLib.TTFont(file)
psName = getPostScriptName(shortName(tt)[0])
print(fontfile, shortName(tt)[0], psName)
df.at[x, 'Font File Name'] = fontfile
df.at[x, 'Windows Name'] = shortName(tt)[0]
df.at[x, 'Postscript Name'] = psName
x = x + 1
df.to_csv("installed-fonts.csv",index=False)
except Exception as e:
print (e)
continue