_p_o_s_t.py 文件源码

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

项目:otRebuilder 作者: Pal3love 项目源码 文件源码
def decode_format_2_0(self, data, ttFont):
        numGlyphs, = struct.unpack(">H", data[:2])
        numGlyphs = int(numGlyphs)
        if numGlyphs > ttFont['maxp'].numGlyphs:
            # Assume the numGlyphs field is bogus, so sync with maxp.
            # I've seen this in one font, and if the assumption is
            # wrong elsewhere, well, so be it: it's hard enough to
            # work around _one_ non-conforming post format...
            numGlyphs = ttFont['maxp'].numGlyphs
        data = data[2:]
        indices = array.array("H")
        indices.fromstring(data[:2*numGlyphs])
        if sys.byteorder != "big":
            indices.byteswap()
        data = data[2*numGlyphs:]
        self.extraNames = extraNames = unpackPStrings(data)
        self.glyphOrder = glyphOrder = [""] * int(ttFont['maxp'].numGlyphs)
        for glyphID in range(numGlyphs):
            index = indices[glyphID]
            if index > 257:
                try:
                    name = extraNames[index-258]
                except IndexError:
                    name = ""
            else:
                # fetch names from standard list
                name = standardGlyphOrder[index]
            glyphOrder[glyphID] = name
        self.build_psNameMapping(ttFont)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号