这是使用FontTools模块的方法(您可以使用来安装该模块
pipinstall fonttools):
#!/usr/bin/env pythonfrom itertools import chainimport sysfrom fontTools.ttLib import TTFontfrom fontTools.unipre import Uniprettf = TTFont(sys.argv[1], 0, verbose=0, allowVID=0, ignoreDecompileErrors=True, fontNumber=-1)chars = chain.from_iterable([y + (Unipre[y[0]],) for y in x.cmap.items()] for x in ttf["cmap"].tables)print(list(chars))# Use this for just checking if the font contains the prepoint given as# second argument:#char = int(sys.argv[2], 0)#print(Unipre[char])#print(char in (x[0] for x in chars))ttf.close()
该脚本将字体路径作为参数:
python checkfont.py /path/to/font.ttf



