From c72295efd26f6a2a150d18f171403ec47a857d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=A3=9E?= Date: Tue, 25 Dec 2018 09:56:31 +0800 Subject: [PATCH 1/2] - delete GetTTFFontName.py from resources --- Example/GetTTFFontName.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Example/GetTTFFontName.py diff --git a/Example/GetTTFFontName.py b/Example/GetTTFFontName.py new file mode 100644 index 0000000..4253409 --- /dev/null +++ b/Example/GetTTFFontName.py @@ -0,0 +1,36 @@ +""" +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 os +from fontTools import ttLib + +FONT_SPECIFIER_NAME_ID = 4 +FONT_SPECIFIER_FAMILY_ID = 1 +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 + +if __name__ == '__main__': + path = "../LGButton/Resources/" + fonts = os.listdir(path) + for font in fonts: + if font.endswith(".ttf") == False: + continue + tt = ttLib.TTFont(path + font) + print("FileName:%s\t\t"%font,"Name: %s Family: %s" % shortName(tt)) From ccccd851d14610f272b3666afdc4e12028a52e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=A3=9E?= Date: Tue, 25 Dec 2018 09:58:06 +0800 Subject: [PATCH 2/2] Delete GetTTFFontName.py --- LGButton/Resources/GetTTFFontName.py | 36 ---------------------------- 1 file changed, 36 deletions(-) delete mode 100644 LGButton/Resources/GetTTFFontName.py diff --git a/LGButton/Resources/GetTTFFontName.py b/LGButton/Resources/GetTTFFontName.py deleted file mode 100644 index e22dd68..0000000 --- a/LGButton/Resources/GetTTFFontName.py +++ /dev/null @@ -1,36 +0,0 @@ -""" -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 os -from fontTools import ttLib - -FONT_SPECIFIER_NAME_ID = 4 -FONT_SPECIFIER_FAMILY_ID = 1 -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 - -if __name__ == '__main__': - path = "./" - fonts = os.listdir(path) - for font in fonts: - if font.endswith(".ttf") == False: - continue - tt = ttLib.TTFont(path + font) - print("FileName:%s\t\t"%font,"Name: %s Family: %s" % shortName(tt))