📄 font_indexing.py
字号:
"""A little example that shows how the various indexing into the fonttables relate to one another. Mainly for mpl developers...."""import matplotlibfrom matplotlib.ft2font import FT2Font, KERNING_DEFAULT, KERNING_UNFITTED, KERNING_UNSCALED#fname = '/usr/share/fonts/sfd/FreeSans.ttf'fname = matplotlib.get_data_path() + '/Vera.ttf'font = FT2Font(fname)font.set_charmap(0)codes = font.get_charmap().items()dsu = [(ccode, glyphind) for glyphind, ccode in codes]dsu.sort()#for ccode, glyphind in dsu: # try: name = font.get_glyph_name(glyphind)# except RuntimeError: pass# else: print '% 4d % 4d %s %s'%(glyphind, ccode, hex(int(ccode)), name)# make a charname to charcode and glyphind dictionarycoded = {}glyphd = {}for glyphind, ccode in codes: name = font.get_glyph_name(glyphind) coded[name] = ccode glyphd[name] = glyphindcode = coded['A']glyph = font.load_char(code)#print glyph.bboxprint glyphd['A'], glyphd['V'], coded['A'], coded['V']print 'AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_DEFAULT)print 'AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_UNFITTED)print 'AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_UNSCALED)print 'AV', font.get_kerning(glyphd['A'], glyphd['T'], KERNING_UNSCALED)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -