def decompile(self, data, ttFont):
    if ((data is not None) and (ttFont is not None)):
        self.decompileHeader(data, ttFont)
    else:
        assert ((data is None) and (ttFont is None)), 'Need both data and ttFont arguments'
    data = self.data
    subHeaderKeys = []
    maxSubHeaderindex = 0
    allKeys = array.array('H')
    allKeys.fromstring(data[:512])
    data = data[512:]
    if (sys.byteorder != 'big'):
        allKeys.byteswap()
    subHeaderKeys = [(key // 8) for key in allKeys]
    maxSubHeaderindex = max(subHeaderKeys)
    subHeaderList = []
    pos = 0
    for i in range((maxSubHeaderindex + 1)):
        subHeader = SubHeader()
        (subHeader.firstCode, subHeader.entryCount, subHeader.idDelta, subHeader.idRangeOffset) = struct.unpack(subHeaderFormat, data[pos:(pos + 8)])
        pos += 8
        giDataPos = ((pos + subHeader.idRangeOffset) - 2)
        giList = array.array('H')
        giList.fromstring(data[giDataPos:(giDataPos + (subHeader.entryCount * 2))])
        if (sys.byteorder != 'big'):
            giList.byteswap()
        subHeader.glyphIndexArray = giList
        subHeaderList.append(subHeader)
    self.data = b''
    self.cmap = cmap = {}
    notdefGI = 0
    for firstByte in range(256):
        subHeadindex = subHeaderKeys[firstByte]
        subHeader = subHeaderList[subHeadindex]
        if (subHeadindex == 0):
            if ((firstByte < subHeader.firstCode) or (firstByte >= (subHeader.firstCode + subHeader.entryCount))):
                continue
            else:
                charCode = firstByte
                offsetIndex = (firstByte - subHeader.firstCode)
                gi = subHeader.glyphIndexArray[offsetIndex]
                if (gi != 0):
                    gi = ((gi + subHeader.idDelta) % 65536)
                else:
                    continue
            cmap[charCode] = gi
        elif subHeader.entryCount:
            charCodeOffset = ((firstByte * 256) + subHeader.firstCode)
            for offsetIndex in range(subHeader.entryCount):
                charCode = (charCodeOffset + offsetIndex)
                gi = subHeader.glyphIndexArray[offsetIndex]
                if (gi != 0):
                    gi = ((gi + subHeader.idDelta) % 65536)
                else:
                    continue
                cmap[charCode] = gi
    glyphOrder = self.ttFont.getGlyphOrder()
    gids = list(cmap.values())
    charCodes = list(cmap.keys())
    lenCmap = len(gids)
    try:
        names = list(map(operator.getitem, ([glyphOrder] * lenCmap), gids))
    except IndexError:
        getGlyphName = self.ttFont.getGlyphName
        names = list(map(getGlyphName, gids))
    list(map(operator.setitem, ([cmap] * lenCmap), charCodes, names))
def decompile(self, data, ttFont):
    if ((data is not None) and (ttFont is not None)):
        self.decompileHeader(data, ttFont)
    else:
        assert ((data is None) and (ttFont is None)), 'Need both data and ttFont arguments'
    data = self.data
    subHeaderKeys = []
    maxSubHeaderindex = 0
    allKeys = array.array('H')
    allKeys.fromstring(data[:512])
    data = data[512:]
    if (sys.byteorder != 'big'):
        allKeys.byteswap()
    subHeaderKeys = [(key // 8) for key in allKeys]
    maxSubHeaderindex = max(subHeaderKeys)
    subHeaderList = []
    pos = 0
    for i in range((maxSubHeaderindex + 1)):
        subHeader = SubHeader()
        (subHeader.firstCode, subHeader.entryCount, subHeader.idDelta, subHeader.idRangeOffset) = struct.unpack(subHeaderFormat, data[pos:(pos + 8)])
        pos += 8
        giDataPos = ((pos + subHeader.idRangeOffset) - 2)
        giList = array.array('H')
        giList.fromstring(data[giDataPos:(giDataPos + (subHeader.entryCount * 2))])
        if (sys.byteorder != 'big'):
            giList.byteswap()
        subHeader.glyphIndexArray = giList
        subHeaderList.append(subHeader)
    self.data = b
    self.cmap = cmap = {}
    notdefGI = 0
    for firstByte in range(256):
        subHeadindex = subHeaderKeys[firstByte]
        subHeader = subHeaderList[subHeadindex]
        if (subHeadindex == 0):
            if ((firstByte < subHeader.firstCode) or (firstByte >= (subHeader.firstCode + subHeader.entryCount))):
                continue
            else:
                charCode = firstByte
                offsetIndex = (firstByte - subHeader.firstCode)
                gi = subHeader.glyphIndexArray[offsetIndex]
                if (gi != 0):
                    gi = ((gi + subHeader.idDelta) % 65536)
                else:
                    continue
            cmap[charCode] = gi
        elif subHeader.entryCount:
            charCodeOffset = ((firstByte * 256) + subHeader.firstCode)
            for offsetIndex in range(subHeader.entryCount):
                charCode = (charCodeOffset + offsetIndex)
                gi = subHeader.glyphIndexArray[offsetIndex]
                if (gi != 0):
                    gi = ((gi + subHeader.idDelta) % 65536)
                else:
                    continue
                cmap[charCode] = gi
    glyphOrder = self.ttFont.getGlyphOrder()
    gids = list(cmap.values())
    charCodes = list(cmap.keys())
    lenCmap = len(gids)
    try:
        names = list(map(operator.getitem, ([glyphOrder] * lenCmap), gids))
    except IndexError:
        getGlyphName = self.ttFont.getGlyphName
        names = list(map(getGlyphName, gids))
    list(map(operator.setitem, ([cmap] * lenCmap), charCodes, names))