_c_m_a_p.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:otRebuilder 作者: Pal3love 项目源码 文件源码
def compile(self, ttFont):
        if self.data:
            return struct.pack(">HHH", self.format, self.length, self.language) + self.data
        cmap = self.cmap
        codes = sorted(cmap.keys())
        if codes: # yes, there are empty cmap tables.
            codes = list(range(codes[0], codes[-1] + 1))
            firstCode = codes[0]
            valueList = [cmap.get(code, ".notdef") for code in codes]
            valueList = map(ttFont.getGlyphID, valueList)
            gids = array.array("H", valueList)
            if sys.byteorder != "big":
                gids.byteswap()
            data = gids.tostring()
        else:
            data = b""
            firstCode = 0
        header = struct.pack(">HHHHH",
                6, len(data) + 10, self.language, firstCode, len(codes))
        return header + data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号