Hi Mr Epeleg,
One way to do it is to scan OS font's dictionaries for common and 'legal' font files.
It is essential to realize that the outcome list might contain only some (or excess) of the list presented in the F360 test dialog box, as ADSK uses also its own proprietary font format.
Also, some system legacy fonts on Windows do not exist in (easily accessible) file form.
I am not sure about apple juice candied Unix, although many common sense similarities .... have prevailed.
Please find below some snippets of the code that might alleviate the pain of tackling the issue; however, the deeper you go, the more convoluted/intricate it is. I am attaching the dump of what is inside the belly of the typical font (a lot of s.... for sure) and an abbreviated executive summary (of Rockwell Condensed). Have fun!
# ONE OF MANY MODULE TO DEAL WITH FONTS ⏳⏳⏳⏳⏳
import fontTools
from fontTools.ttLib import TTFont
# WHERE TO FIND THE FONTS
fontResourcePathsLst = [ ['C:\\Windows\\Fonts\\','.ttf'],
['C:\\Windows\\Fonts\\','.otf'],
['C:\\Program Files (x86)\\Adobe\\Acrobat DC\\Resource\\Font\\','.otf'],
['C:\\Program Files (x86)\\Adobe\\Acrobat DC\\Resource\\CIDFont\\','.otf'],
['D:\\???????\\FontAddins\\','.ttf']]
# LIST FONTS VIA OS's FILE SYSTEM
def getFontNamesTable( vDict, fontSystemFiles, fontNamesTable, charSet ):
fontNamesTable = [['fontFamilyName', 'fontSubFamilyName', 'isItalic', 'isBold', 'lfWeight', 'uniqueFontIdentifier', 'fullFontName', 'fontFilePath', 'fontType', 'licenseType', 'mapTableNames']]
for fontFilePath in fontSystemFiles:
ttf = TTFont( fontFilePath, 0, allowVID=0, ignoreDecompileErrors=True, fontNumber=-1)
nameMap = ttf['name']
fontFamilyName = None
fontSubFamilyName = None
uniqueFontIdentifier = None
fullFontName = None
isItalic = False
isBold = False
lfWeight = 400
fontType = 0
for nameRecIdx in range(len(nameMap.names)):
nameRec = nameMap.names[nameRecIdx]
if nameRec.nameID == Constants.FONT_FAMILY_NAME:
fontFamilyName = str(NameRecord.toUnicode( nameRec, errors='strict'))
elif nameRec.nameID == Constants.FONT_COPYRIGHT_NOTICE:
fontCopyRight = NameRecord.toUnicode( nameRec, errors='strict')
if fontCopyRight == '':
fontCopyRight == 'None'
fontCopyRight = fontCopyRight.replace( ',', '|' )
elif nameRec.nameID == Constants.FONT_SUBFAMILY_NAME:
fontSubFamilyName = NameRecord.toUnicode( nameRec, errors='strict')
( isItalic, isBold, lfWeight ) = getItalicBoldWeight( fontSubFamilyName )
elif nameRec.nameID == Constants.FONT_UNIQUE_IDENTIFIER:
uniqueFontIdentifier = NameRecord.toUnicode( nameRec, errors='strict')
uniqueFontIdentifier = uniqueFontIdentifier.replace( ',', ' ' ) # Lucida and others has comma char here ????
uniqueFontIdentifier = uniqueFontIdentifier.replace( u',', u' ')
elif nameRec.nameID == Constants.FONT_FULL_NAME:
fullFontName = NameRecord.toUnicode( nameRec, errors='strict')
if fontFamilyName and fontSubFamilyName and uniqueFontIdentifier and fullFontName:
mapTableNames = str(sorted(ttf.keys()))
fontNamesTableRec = [fontFamilyName, fontSubFamilyName, isItalic, isBold, lfWeight, uniqueFontIdentifier, fullFontName, fontFilePath, fontCopyRight, mapTableNames]
fontNamesTable.append( fontNamesTableRec )
break
return fontNamesTable
{
"HEADER": {
"CreatedBy": "TextShape",
"Version": 5.123,
"Author": "Michael Tomsia, PhD",
"Content": "Window True Type Font Property Dump",
"CreationDate": "18 Dec 2021 10:40:14",
"FontName": "",
"FontStyle": "NORMAL ANSI",
"fontFilePath": "",
"platEncIDSet": "",
"platformIDSet": "",
"languageSet": "",
"glyphExist": "",
"FontHeight": ""
},
"LOGFONT": {
"lfFaceName": "Rockwell Condensed",
"lfHeight": 75,
"lfWidth": 21,
"lfEscapement": 0,
"lfOrientation": 0,
"lfWeight": 400,
"lfItalic": 0,
"lfUnderline": 0,
"lfStrikeOut": 0,
"lfCharSet": 0,
"lfOutPrecision": 3,
"lfClipPrecision": 2,
"lfPitchAndFamily": 1,
"fonttypeStr": "TRUETYPE",
"fonttype": 4
},
"TEXTMETRIC": {
"tmHeight": 75,
"tmAscent": 60,
"tmDescent": 15,
"tmInternalLeading": 11,
"tmExternalLeading": 0,
"tmAveCharWidth": 21,
"tmMaxCharWidth": 74,
"tmWeight": 400,
"tmOverhang": 0,
"tmDigitizedAspectX": 192,
"tmDigitizedAspectY": 192,
"tmFirstChar": 32,
"tmLastChar": 0,
"tmDefaultChar": 2,
"tmBreakChar": -5,
"tmItalic": 31,
"tmUnderline": 0,
"tmStruckOut": 32,
"tmPitchAndFamily": 0,
"tmCharSet": 0,
"tmCharSetName": "ANSI"
}
}
Regards
MichaelT
MichaelT