eliwang

通过一个例子,了解一下fontTools库的简单使用

# coding:utf-8
from fontTools.ttLib import TTFont

tf = TTFont(\'ztk01.woff\') #实例化字体对象,也可以从内存中读取数据 tf = TTFont(BytesIO(data)) 
tf.saveXML(\'ztk01.xml\') #存储为xml格式文件
uninames = tf.getGlyphNames()[1:-1] #获取所有字符的unicode编码
print(uninames)
#[\'uniE06A\', \'uniE0C0\', \'uniE0D2\', \'uniE0DB\', \'uniE0E1\', \'uniE1A4\', \'uniE1E0\', ...,\'uniF62A\', \'uniF66C\']
cos = tf[\'glyf\'][uninames[1]].coordinates #获取某个字符的坐标
print(cos)
#GlyphCoordinates([(543, 826),(918, 850),(1124, 844),(666, 841),(1110, 826),...,(672, 411)])

 

分类:

技术点:

相关文章:

  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
  • 2021-09-18
  • 2023-03-24
  • 2021-10-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-20
  • 2022-01-25
  • 2022-12-23
  • 2022-01-20
  • 2021-06-21
  • 2021-08-12
相关资源
相似解决方案