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
    (segCountX2, searchRange, entrySelector, rangeShift) = struct.unpack('>4H', data[:8])
    data = data[8:]
    segCount = (segCountX2 // 2)
    allCodes = array.array('H')
    allCodes.fromstring(data)
    self.data = data = None
    if (sys.byteorder != 'big'):
        allCodes.byteswap()
    endCode = allCodes[:segCount]
    allCodes = allCodes[(segCount + 1):]
    startCode = allCodes[:segCount]
    allCodes = allCodes[segCount:]
    idDelta = allCodes[:segCount]
    allCodes = allCodes[segCount:]
    idRangeOffset = allCodes[:segCount]
    glyphIndexArray = allCodes[segCount:]
    lenGIArray = len(glyphIndexArray)
    charCodes = []
    gids = []
    for i in range((len(startCode) - 1)):
        start = startCode[i]
        delta = idDelta[i]
        rangeOffset = idRangeOffset[i]
        partial = ((((rangeOffset // 2) - start) + i) - len(idRangeOffset))
        rangeCharCodes = list(range(startCode[i], (endCode[i] + 1)))
        charCodes.extend(rangeCharCodes)
        if (rangeOffset == 0):
            gids.extend([((charCode + delta) & 65535) for charCode in rangeCharCodes])
        else:
            for charCode in rangeCharCodes:
                index = (charCode + partial)
                assert (index < lenGIArray), ('In format 4 cmap, range (%d), the calculated index (%d) into the glyph index array  is not less than the length of the array (%d) !' % (i, index, lenGIArray))
                if (glyphIndexArray[index] != 0):
                    glyphID = (glyphIndexArray[index] + delta)
                else:
                    glyphID = 0
                gids.append((glyphID & 65535))
    self.cmap = cmap = {}
    lenCmap = len(gids)
    glyphOrder = self.ttFont.getGlyphOrder()
    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
    (segCountX2, searchRange, entrySelector, rangeShift) = struct.unpack('>4H', data[:8])
    data = data[8:]
    segCount = (segCountX2 // 2)
    allCodes = array.array('H')
    allCodes.fromstring(data)
    self.data = data = None
    if (sys.byteorder != 'big'):
        allCodes.byteswap()
    endCode = allCodes[:segCount]
    allCodes = allCodes[(segCount + 1):]
    startCode = allCodes[:segCount]
    allCodes = allCodes[segCount:]
    idDelta = allCodes[:segCount]
    allCodes = allCodes[segCount:]
    idRangeOffset = allCodes[:segCount]
    glyphIndexArray = allCodes[segCount:]
    lenGIArray = len(glyphIndexArray)
    charCodes = []
    gids = []
    for i in range((len(startCode) - 1)):
        start = startCode[i]
        delta = idDelta[i]
        rangeOffset = idRangeOffset[i]
        partial = ((((rangeOffset // 2) - start) + i) - len(idRangeOffset))
        rangeCharCodes = list(range(startCode[i], (endCode[i] + 1)))
        charCodes.extend(rangeCharCodes)
        if (rangeOffset == 0):
            gids.extend([((charCode + delta) & 65535) for charCode in rangeCharCodes])
        else:
            for charCode in rangeCharCodes:
                index = (charCode + partial)
                assert (index < lenGIArray), ('In format 4 cmap, range (%d), the calculated index (%d) into the glyph index array  is not less than the length of the array (%d) !' % (i, index, lenGIArray))
                if (glyphIndexArray[index] != 0):
                    glyphID = (glyphIndexArray[index] + delta)
                else:
                    glyphID = 0
                gids.append((glyphID & 65535))
    self.cmap = cmap = {}
    lenCmap = len(gids)
    glyphOrder = self.ttFont.getGlyphOrder()
    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))