If I have glyph ids like below how can I get the unicode from them, the language is python that I am working on ? Also what I understand the second value is the glyph id but what do we call the first value and the third value?

(582, 'uni0246', 'LATIN CAPITAL LETTER E WITH STROKE'), (583, 'uni0247', 'LATIN SMALL LETTER E WITH STROKE'), (584, 'uni0248', 'LATIN CAPITAL LETTER J WITHSTROKE'), (585, 'uni0249', 'LATIN SMALL LETTER J WITH STROKE')

Kindly reply.

Actually I am trying to get the unicode from a given ttf file in python.Here is the code :

from fontTools.ttLib import TTFont

from fontTools.unicode import Unicode

from ttfquery import ttfgroups

from fontTools.ttLib.tables import _c_m_a_p

from itertools import chain

ttfgroups.buildTable()

ttf = TTFont(sys.argv[1], 0, verbose=0, allowVID=0,

ignoreDecompileErrors=True,

fontNumber=-1)

chars = chain.from_iterable([y + (Unicode[y[0]],) for y in x.cmap.items()] for x in ttf["cmap"].tables)

print(list(chars))`

This code I got from stackoverflow only but this gives the above output and not what I require. So could anybody please tell me how to fetch the unicodes from the ttf file or is it fine to convert the glyphid to unicode, will it yield to actual unicode ?

解决方案

You can use the first field: unichr(x[0]), or equivalently the second field. Then you remove the "uni" part ([3:]) and you convert it to a hexadecimal valu'Ɇ'e, then to a character. Of course, the first method is faster and simpler.

unichr(int(x[1][3:], 16)) #for the first item you've showed, returns 'Ɇ', for the second 'ɇ'

If you use python3, chr instead of unichr.

python返回unicode_我们如何从python中的字形id获取unicode?相关推荐

  1. js中document通过ID获取的一些使用方法

    js中document通过ID获取的一些使用方法 document.getElementById("link").href;  document.getElementById(&q ...

  2. python返回json数据_python和flask中返回JSON数据的方法

    在python中可以使用json将数据格式化为JSON格式: 1.将字典转换成JSON数据格式: s=['张三','年龄','姓名'] t={} t['data']=s return json.dum ...

  3. python min函数 索引_使用列表中的max()/ min()获取返回的max或min项的索引

    Nico Schlöme.. 14 我也对此感兴趣,并使用perfplot(我的宠物项目)比较了一些建议的解决方案. numpy.argmin(x) 对于足够大的列表来说,这是最快的方法,即使从输入l ...

  4. java执行python返回null_[转]java调用python脚本以及通过Process.waitFor()直接调用python模块返回错误代码1的一种解决办法...

    常见的java调用python脚本方式 通过jython提供的类库实现 通过Runtime.getRuntime()开启进程来执行脚本文件 通过jython提供的类库实现 通过jython实现的话,我 ...

  5. Android项目,library中根据资源id获取资源

    场景     BaseActivity放在library中,所有页面都有一个返回按钮,id为id_iv_back.想在BaseActivity统一设置返回点击事件.但是library无法获取app的R ...

  6. python返回舱匹配个数_Python | 用作数据类型(解释:头等舱,闭幕)

    python返回舱匹配个数 In python, a function is a type. That's why python function is known as "First cl ...

  7. python input与返回值-python中使用input()函数获取用户输入值方式

    我们编写程序最终目的还是来解决实际问题,所以必然会遇到输入输出的交互问题,python中提供了input函数用来获取用户的输入,我们可以用以下程序演示. user_gender = input(&qu ...

  8. python指定返回类型_如何在python中指定方法返回类型列表 - python

    假设我有一个类似下面的方法 def validate(self, item:dict, attrs:dict)-> list: 如果我想更具体一点,告诉我我的返回类型是 验证消息? 我应该如何实 ...

  9. python返回绝对值的函数_Python中用于返回绝对值的abs()方法

    Python中用于返回绝对值的abs()方法 方法abs() 返回x的绝对值,-x-零之间的(正极)的距离. 语法 以下是abs()方法的语法: abs( x ) 参数 x -- 这是一个数值表达式 ...

最新文章

  1. C#程序以管理员权限运行
  2. 201521123087 《Java程序设计》第9周学习总结
  3. 关于前台调用后台事件__doPostBack函数
  4. swoole的安装(已经做测试成功)
  5. 也拿baidu搜索开玩笑!
  6. 自动驾驶算法-滤波器系列(四)——不同运动模型在KF/EKF中的应用
  7. 在Windows 下如何使用 AspNetCore Api 和 consul
  8. 【逗老师带你学IT】阿里云监控报警回调+转发企业微信+转发SnmpTrap+PRTG
  9. ios百度地图开发之路径规划
  10. 如何用软件测试交易系统的胜率,通达信官网程序交易测试
  11. 江西理工大学计算机网络基础试卷,无线网络技术作业(江西理工大学期末复习)...
  12. 【Spring Boot JPA】ManyToOne OneToMany学习笔记
  13. 点名器实现的随机原理(实现随机点名器)
  14. hiper工具查看页面加载时间
  15. 【AWS云从业者基础知识笔记】——模块5:存储和数据库
  16. VB.net判断字符串是否以数字开头
  17. Java第三章刘珊珊同学参加了Java课程的学习,她父亲和母亲承诺。
  18. 微信表白墙小程序源码
  19. json 与 string 的转换
  20. 计算机组成原理的简单学习

热门文章

  1. SAP Cloud Connector里点击Check按钮的可达性roundtrip实现
  2. 使用函数BAPISDORDER_GETDETAILEDLIST读取S/4HANA中Sales Order行项目数据
  3. 往ABAP gateway system上和Cloud Foundry上部署HTML5应用
  4. python decorator模块_Python decorator module
  5. linux旧版本如何升级成新版本,Linux如何升级软件版本,
  6. tl r402路由器设置_tplink wr847n无线路由器如何设置 tplink wr847n无线路由器设置方法【详解】...
  7. 循环码差错图样matlab,基于MATLAB的(15,7)循环码的编译仿真.doc
  8. TCP 三次握手四次挥手
  9. Linux 查看目录常用命令
  10. cvs数据导入工具 oracle_为中国企业打造的研发项目管理工具ONES Project已支持Jira数据导入...