0
0 Комментариев

#!/usr/bin/env python

"""
From
https://github.com/gddc/ttfquery/blob/master/ttfquery/describe.py
and
http://www.starrhorne.com/2012/01/18/how-to-extract-font-names-from-ttf-files-using-python-and-our-old-friend-the-command-line.html

ported to Python 3
"""

import sys
from fontTools import ttLib

FONT_SPECIFIER_VER_ID = sys.argv[2]
def shortName( font ):
"""Get the short name from the font's names table"""
ver = ""
for record in font['name'].names:
if b'\x00' in record.string:
ver_str = record.string.decode('utf-16-be')
else:
ver_str = record.string.decode('utf-8')
if record.nameID == FONT_SPECIFIER_VER_ID and not ver:
ver = ver_str
return ver

tt = ttLib.TTFont(sys.argv[1])
print("%s" % shortName(tt))

Запускаю так: python.exe get_ver.py BebasNeue.otf 5

Реакции 0


Добавить комментарий