py23 Use bytechr() instead of chr()
diff --git a/Lib/fontTools/ttLib/tables/E_B_D_T_.py b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
index 6562925..d8ea500 100644
--- a/Lib/fontTools/ttLib/tables/E_B_D_T_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
@@ -222,7 +222,7 @@
curByte = curByte << 1
if curBit == '1':
curByte |= 1
- byteList.append(chr(curByte))
+ byteList.append(bytechr(curByte))
return ''.join(byteList)
def _memoize(f):
@@ -248,7 +248,7 @@
result = result << 1
result |= byte & 1
byte = byte >> 1
- return chr(result)
+ return bytechr(result)
# This section of code is for reading and writing image data to/from XML.
@@ -528,7 +528,7 @@
curByte = _reverseBytes(self.imageData[secondByteLoc])
secondHalf = ord(curByte) << numBitsCut
newByte = (firstHalf | secondHalf) & ((1<<numBits)-1)
- dataList.append(chr(newByte))
+ dataList.append(bytechr(newByte))
# The way the data is kept is opposite the algorithm used.
data = ''.join(dataList)
@@ -566,7 +566,7 @@
ordDataList[secondByteLoc] |= secondByte
# Save the image data with the bits going the correct way.
- self.imageData = _reverseBytes("".join(map(chr, ordDataList)))
+ self.imageData = _reverseBytes("".join(map(bytechr, ordDataList)))
class ByteAlignedBitmapMixin:
diff --git a/Lib/fontTools/ttLib/tables/S_I_N_G_.py b/Lib/fontTools/ttLib/tables/S_I_N_G_.py
index 16974a5..caafb05 100644
--- a/Lib/fontTools/ttLib/tables/S_I_N_G_.py
+++ b/Lib/fontTools/ttLib/tables/S_I_N_G_.py
@@ -57,12 +57,12 @@
def compile(self, ttFont):
- self.nameLength = chr(len(self.baseGlyphName))
+ self.nameLength = bytechr(len(self.baseGlyphName))
self.uniqueName = self.compilecompileUniqueName(self.uniqueName, 28)
METAMD5List = eval(self.METAMD5)
self.METAMD5 = ""
for val in METAMD5List:
- self.METAMD5 = self.METAMD5 + chr(val)
+ self.METAMD5 = self.METAMD5 + bytechr(val)
assert (len(self.METAMD5) == 16), "Failed to pack 16 byte MD5 hash in SING table"
data = sstruct.pack(SINGFormat, self)
data = data + self.baseGlyphName
diff --git a/Lib/fontTools/ttLib/tables/_h_d_m_x.py b/Lib/fontTools/ttLib/tables/_h_d_m_x.py
index ebe0a29..8e50ae0 100644
--- a/Lib/fontTools/ttLib/tables/_h_d_m_x.py
+++ b/Lib/fontTools/ttLib/tables/_h_d_m_x.py
@@ -36,10 +36,10 @@
data = sstruct.pack(hdmxHeaderFormat, self)
items = sorted(self.hdmx.items())
for ppem, widths in items:
- data = data + chr(ppem) + chr(max(widths.values()))
+ data = data + bytechr(ppem) + bytechr(max(widths.values()))
for glyphID in range(len(glyphOrder)):
width = widths[glyphOrder[glyphID]]
- data = data + chr(width)
+ data = data + bytechr(width)
data = data + pad
return data
diff --git a/Lib/fontTools/ttLib/tables/_h_e_a_d.py b/Lib/fontTools/ttLib/tables/_h_e_a_d.py
index 2c11559..90a41ab 100644
--- a/Lib/fontTools/ttLib/tables/_h_e_a_d.py
+++ b/Lib/fontTools/ttLib/tables/_h_e_a_d.py
@@ -141,7 +141,7 @@
mask = int("FF" * bytes, 16)
data = ""
while v:
- data = chr(v & 0xff) + data
+ data = bytechr(v & 0xff) + data
v = (v >> 8) & mask
data = (bytes - len(data)) * "\0" + data
assert len(data) == 8, "long too long"
diff --git a/Lib/fontTools/ttLib/tables/_p_o_s_t.py b/Lib/fontTools/ttLib/tables/_p_o_s_t.py
index d23b209..d6a77c5 100644
--- a/Lib/fontTools/ttLib/tables/_p_o_s_t.py
+++ b/Lib/fontTools/ttLib/tables/_p_o_s_t.py
@@ -225,6 +225,6 @@
def packPStrings(strings):
data = ""
for s in strings:
- data = data + chr(len(s)) + s
+ data = data + bytechr(len(s)) + s
return data
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index ef81ed1..4866807 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -406,7 +406,7 @@
def writeUInt24(self, value):
assert 0 <= value < 0x1000000
- self.items.append(''.join(chr(v) for v in (value>>16, (value>>8)&0xFF, value&0xff)))
+ self.items.append(''.join(bytechr(v) for v in (value>>16, (value>>8)&0xFF, value&0xff)))
def writeLong(self, value):
self.items.append(struct.pack(">l", value))