2to3 --fix=xrange
diff --git a/Lib/fontTools/ttLib/tables/E_B_D_T_.py b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
index 97b371d..e38abb7 100644
--- a/Lib/fontTools/ttLib/tables/E_B_D_T_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
@@ -206,7 +206,7 @@
for curByte in data:
value = ord(curByte)
numBitsCut = min(8, numBits)
- for i in xrange(numBitsCut):
+ for i in range(numBitsCut):
if value & 0x1:
binaryList.append('1')
else:
@@ -217,7 +217,7 @@
def _binary2data(binary):
byteList = []
- for bitLoc in xrange(0, len(binary), 8):
+ for bitLoc in range(0, len(binary), 8):
byteString = binary[bitLoc:bitLoc+8]
curByte = 0
for curBit in reversed(byteString):
@@ -246,7 +246,7 @@
return string.join(map(_reverseBytes, data), "")
byte = ord(data)
result = 0
- for i in xrange(8):
+ for i in range(8):
result = result << 1
result |= byte & 1
byte = byte >> 1
@@ -272,7 +272,7 @@
writer.begintag('rowimagedata', bitDepth=bitDepth, width=metrics.width, height=metrics.height)
writer.newline()
- for curRow in xrange(metrics.height):
+ for curRow in range(metrics.height):
rowData = bitmapObject.getRow(curRow, bitDepth=bitDepth, metrics=metrics)
writer.simpletag('row', value=hexStr(rowData))
writer.newline()
@@ -306,7 +306,7 @@
writer.begintag('bitwiseimagedata', bitDepth=bitDepth, width=metrics.width, height=metrics.height)
writer.newline()
- for curRow in xrange(metrics.height):
+ for curRow in range(metrics.height):
rowData = bitmapObject.getRow(curRow, bitDepth=1, metrics=metrics, reverseBytes=True)
rowData = _data2binary(rowData, metrics.width)
# Make the output a readable ASCII art form.
@@ -512,7 +512,7 @@
dataList = []
bitRange = self._getBitRange(row, bitDepth, metrics)
stepRange = bitRange + (8,)
- for curBit in xrange(*stepRange):
+ for curBit in range(*stepRange):
endBit = min(curBit+8, bitRange[1])
numBits = endBit - curBit
cutPoint = curBit % 8
@@ -551,7 +551,7 @@
for row, data in enumerate(dataRows):
bitRange = self._getBitRange(row, bitDepth, metrics)
stepRange = bitRange + (8,)
- for curBit, curByte in itertools.izip(xrange(*stepRange), data):
+ for curBit, curByte in itertools.izip(range(*stepRange), data):
endBit = min(curBit+8, bitRange[1])
cutPoint = curBit % 8
firstByteLoc = curBit / 8
@@ -698,7 +698,7 @@
(numComponents,) = struct.unpack(">H", data[:2])
data = data[2:]
self.componentArray = []
- for i in xrange(numComponents):
+ for i in range(numComponents):
curComponent = EbdtComponent()
dummy, data = sstruct.unpack2(ebdtComponentFormat, data, curComponent)
curComponent.name = self.ttFont.getGlyphName(curComponent.glyphCode)
@@ -723,7 +723,7 @@
(numComponents,) = struct.unpack(">H", data[:2])
data = data[2:]
self.componentArray = []
- for i in xrange(numComponents):
+ for i in range(numComponents):
curComponent = EbdtComponent()
dummy, data = sstruct.unpack2(ebdtComponentFormat, data, curComponent)
curComponent.name = self.ttFont.getGlyphName(curComponent.glyphCode)
diff --git a/Lib/fontTools/ttLib/tables/E_B_L_C_.py b/Lib/fontTools/ttLib/tables/E_B_L_C_.py
index 4d64275..599a196 100644
--- a/Lib/fontTools/ttLib/tables/E_B_L_C_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_L_C_.py
@@ -76,7 +76,7 @@
dummy, data = sstruct.unpack2(eblcHeaderFormat, data, self)
self.strikes = []
- for curStrikeIndex in xrange(self.numSizes):
+ for curStrikeIndex in range(self.numSizes):
curStrike = Strike()
self.strikes.append(curStrike)
curTable = curStrike.bitmapSizeTable
@@ -89,7 +89,7 @@
for curStrike in self.strikes:
curTable = curStrike.bitmapSizeTable
- for subtableIndex in xrange(curTable.numberOfIndexSubTables):
+ for subtableIndex in range(curTable.numberOfIndexSubTables):
lowerBound = curTable.indexSubTableArrayOffset + subtableIndex * indexSubTableArraySize
upperBound = lowerBound + indexSubTableArraySize
data = origData[lowerBound:upperBound]
@@ -429,11 +429,11 @@
def decompile(self):
numGlyphs = self.lastGlyphIndex - self.firstGlyphIndex + 1
- indexingOffsets = [glyphIndex * offsetDataSize for glyphIndex in xrange(numGlyphs+2)]
+ indexingOffsets = [glyphIndex * offsetDataSize for glyphIndex in range(numGlyphs+2)]
indexingLocations = zip(indexingOffsets, indexingOffsets[1:])
offsetArray = [struct.unpack(dataFormat, self.data[slice(*loc)])[0] for loc in indexingLocations]
- glyphIds = range(self.firstGlyphIndex, self.lastGlyphIndex+1)
+ glyphIds = list(range(self.firstGlyphIndex, self.lastGlyphIndex+1))
modifiedOffsets = [offset + self.imageDataOffset for offset in offsetArray]
self.locations = zip(modifiedOffsets, modifiedOffsets[1:])
@@ -448,13 +448,13 @@
glyphIds = map(ttFont.getGlyphID, self.names)
# Make sure that all ids are sorted strictly increasing.
- assert all(glyphIds[i] < glyphIds[i+1] for i in xrange(len(glyphIds)-1))
+ assert all(glyphIds[i] < glyphIds[i+1] for i in range(len(glyphIds)-1))
# Run a simple algorithm to add skip glyphs to the data locations at
# the places where an id is not present.
idQueue = deque(glyphIds)
locQueue = deque(self.locations)
- allGlyphIds = range(self.firstGlyphIndex, self.lastGlyphIndex+1)
+ allGlyphIds = list(range(self.firstGlyphIndex, self.lastGlyphIndex+1))
allLocations = []
for curId in allGlyphIds:
if curId != idQueue[0]:
@@ -521,15 +521,15 @@
(self.imageSize,) = struct.unpack(">L", self.data[:4])
self.metrics = BigGlyphMetrics()
sstruct.unpack2(bigGlyphMetricsFormat, self.data[4:], self.metrics)
- glyphIds = range(self.firstGlyphIndex, self.lastGlyphIndex+1)
- offsets = [self.imageSize * i + self.imageDataOffset for i in xrange(len(glyphIds)+1)]
+ glyphIds = list(range(self.firstGlyphIndex, self.lastGlyphIndex+1))
+ offsets = [self.imageSize * i + self.imageDataOffset for i in range(len(glyphIds)+1)]
self.locations = zip(offsets, offsets[1:])
self.names = map(self.ttFont.getGlyphName, glyphIds)
def compile(self, ttFont):
glyphIds = map(ttFont.getGlyphID, self.names)
# Make sure all the ids are consecutive. This is required by Format 2.
- assert glyphIds == range(self.firstGlyphIndex, self.lastGlyphIndex+1), "Format 2 ids must be consecutive."
+ assert glyphIds == list(range(self.firstGlyphIndex, self.lastGlyphIndex+1)), "Format 2 ids must be consecutive."
self.imageDataOffset = min(zip(*self.locations)[0])
dataList = [EblcIndexSubTable.compile(self, ttFont)]
@@ -546,7 +546,7 @@
(numGlyphs,) = struct.unpack(">L", self.data[:4])
data = self.data[4:]
- indexingOffsets = [glyphIndex * codeOffsetPairSize for glyphIndex in xrange(numGlyphs+2)]
+ indexingOffsets = [glyphIndex * codeOffsetPairSize for glyphIndex in range(numGlyphs+2)]
indexingLocations = zip(indexingOffsets, indexingOffsets[1:])
glyphArray = [struct.unpack(codeOffsetPairFormat, data[slice(*loc)]) for loc in indexingLocations]
glyphIds, offsets = map(list, zip(*glyphArray))
@@ -589,9 +589,9 @@
self.metrics, data = sstruct.unpack2(bigGlyphMetricsFormat, data, BigGlyphMetrics())
(numGlyphs,) = struct.unpack(">L", data[:4])
data = data[4:]
- glyphIds = [struct.unpack(">H", data[2*i:2*(i+1)])[0] for i in xrange(numGlyphs)]
+ glyphIds = [struct.unpack(">H", data[2*i:2*(i+1)])[0] for i in range(numGlyphs)]
- offsets = [self.imageSize * i + self.imageDataOffset for i in xrange(len(glyphIds)+1)]
+ offsets = [self.imageSize * i + self.imageDataOffset for i in range(len(glyphIds)+1)]
self.locations = zip(offsets, offsets[1:])
self.names = map(self.ttFont.getGlyphName, glyphIds)
diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
index 6996242..3b25593 100644
--- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py
+++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
@@ -182,7 +182,7 @@
glyphIdArray.fromstring(self.data)
self.cmap = cmap = {}
lenArray = len(glyphIdArray)
- charCodes = range(lenArray)
+ charCodes = list(range(lenArray))
names = map(self.ttFont.getGlyphName, glyphIdArray)
map(operator.setitem, [cmap]*lenArray, charCodes, names)
@@ -195,7 +195,7 @@
charCodeList.sort()
charCodes = [entry[0] for entry in charCodeList]
valueList = [entry[1] for entry in charCodeList]
- assert charCodes == range(256)
+ assert charCodes == list(range(256))
valueList = map(ttFont.getGlyphID, valueList)
glyphIdArray = array.array("B", valueList)
@@ -663,7 +663,7 @@
charCodes = []
gids = []
for i in range(len(startCode) - 1): # don't do 0xffff!
- rangeCharCodes = range(startCode[i], endCode[i] + 1)
+ rangeCharCodes = list(range(startCode[i], endCode[i] + 1))
charCodes = charCodes + rangeCharCodes
for charCode in rangeCharCodes:
rangeOffset = idRangeOffset[i]
@@ -780,7 +780,7 @@
indices = []
for charCode in range(startCode[i], endCode[i] + 1):
indices.append(cmap[charCode])
- if (indices == range(indices[0], indices[0] + len(indices))):
+ if (indices == list(range(indices[0], indices[0] + len(indices)))):
idDeltaTemp = self.setIDDelta(indices[0] - startCode[i])
idDelta.append( idDeltaTemp)
idRangeOffset.append(0)
@@ -853,7 +853,7 @@
self.cmap = cmap = {}
lenArray = len(glyphIndexArray)
- charCodes = range(firstCode, firstCode + lenArray )
+ charCodes = list(range(firstCode, firstCode + lenArray))
glyphOrder = self.ttFont.getGlyphOrder()
try:
names = map(operator.getitem, [glyphOrder]*lenArray, glyphIndexArray )
@@ -868,7 +868,7 @@
cmap = self.cmap
codes = cmap.keys()
if codes: # yes, there are empty cmap tables.
- codes = range(codes[0], codes[-1] + 1)
+ 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)
@@ -933,7 +933,7 @@
startCharCode, endCharCode, glyphID = struct.unpack(">LLL",data[pos:pos+12] )
pos += 12
lenGroup = 1 + endCharCode - startCharCode
- charCodes += range(startCharCode, endCharCode +1)
+ charCodes += list(range(startCharCode, endCharCode +1))
gids += self._computeGIDs(glyphID, lenGroup)
self.data = data = None
self.cmap = cmap = {}
@@ -1047,7 +1047,7 @@
self._format_step = 1
def _computeGIDs(self, startingGlyph, numberOfGlyphs):
- return range(startingGlyph, startingGlyph + numberOfGlyphs)
+ return list(range(startingGlyph, startingGlyph + numberOfGlyphs))
def _IsInSameRun(self, glyphID, lastGlyphID, charCode, lastCharCode):
return (glyphID == 1 + lastGlyphID) and (charCode == 1 + lastCharCode)
@@ -1128,7 +1128,7 @@
startOffset += 4
firstBaseUV = cvtToUVS(uv)
cnt = addtlCnt+1
- baseUVList = range(firstBaseUV, firstBaseUV+cnt)
+ baseUVList = list(range(firstBaseUV, firstBaseUV+cnt))
glyphList = [None]*cnt
localUVList = zip(baseUVList, glyphList)
try:
diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
index 3394488..cdc8213 100644
--- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py
+++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
@@ -913,13 +913,13 @@
def __getitem__(self, k):
if isinstance(k, slice):
- indices = xrange(*k.indices(len(self)))
+ indices = range(*k.indices(len(self)))
return [self[i] for i in indices]
return self._a[2*k],self._a[2*k+1]
def __setitem__(self, k, v):
if isinstance(k, slice):
- indices = xrange(*k.indices(len(self)))
+ indices = range(*k.indices(len(self)))
for j,i in enumerate(indices):
self[i] = v[j]
return
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index 3d80ad8..fcbc5e1 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -305,7 +305,7 @@
if internedTables is None:
internedTables = {}
items = self.items
- iRange = range(len(items))
+ iRange = list(range(len(items)))
if hasattr(self, "Extension"):
newTree = 1
@@ -342,7 +342,7 @@
done[self] = 1
numItems = len(self.items)
- iRange = range(numItems)
+ iRange = list(range(numItems))
iRange.reverse()
if hasattr(self, "Extension"):
diff --git a/Lib/fontTools/ttLib/tables/otTables.py b/Lib/fontTools/ttLib/tables/otTables.py
index 557940a..e087798 100644
--- a/Lib/fontTools/ttLib/tables/otTables.py
+++ b/Lib/fontTools/ttLib/tables/otTables.py
@@ -219,7 +219,7 @@
classList = rawTable["ClassValueArray"]
lenList = len(classList)
glyphID = font.getGlyphID(start)
- gidList = range(glyphID, glyphID + len(classList))
+ gidList = list(range(glyphID, glyphID + len(classList)))
keyList = [getGlyphName(glyphID) for glyphID in gidList]
map(operator.setitem, [classDefs]*lenList, keyList, classList)
@@ -231,7 +231,7 @@
end = rec.End
cls = rec.Class
classDefs[start] = cls
- glyphIDs = range(font.getGlyphID(start) + 1, font.getGlyphID(end))
+ glyphIDs = list(range(font.getGlyphID(start) + 1, font.getGlyphID(end)))
lenList = len(glyphIDs)
keyList = [getGlyphName(glyphID) for glyphID in glyphIDs]
map(operator.setitem, [classDefs]*lenList, keyList, [cls]*lenList)