diff --git a/Lib/fontTools/subset/__init__.py b/Lib/fontTools/subset/__init__.py index e3e6f74d9..3b411cdf9 100644 --- a/Lib/fontTools/subset/__init__.py +++ b/Lib/fontTools/subset/__init__.py @@ -2075,7 +2075,7 @@ def remapComponentsFast(self, glyphidmap): elif flags & 0x0080: i += 8 # WE_HAVE_A_TWO_BY_TWO more = flags & 0x0020 # MORE_COMPONENTS - self.data = data.tostring() + self.data = data.tobytes() @_add_method(ttLib.getTableClass('glyf')) def closure_glyphs(self, s): diff --git a/Lib/fontTools/ttLib/tables/G_P_K_G_.py b/Lib/fontTools/ttLib/tables/G_P_K_G_.py index 511fd0d71..601b3c265 100644 --- a/Lib/fontTools/ttLib/tables/G_P_K_G_.py +++ b/Lib/fontTools/ttLib/tables/G_P_K_G_.py @@ -56,7 +56,7 @@ class table_G_P_K_G_(DefaultTable.DefaultTable): GMAPoffsets[i] = pos gmapArray = array.array("I", GMAPoffsets) if sys.byteorder != "big": gmapArray.byteswap() - dataList.append(gmapArray.tostring()) + dataList.append(gmapArray.tobytes()) glyphletOffsets[0] = pos for i in range(1, self.numGlyplets +1): @@ -64,7 +64,7 @@ class table_G_P_K_G_(DefaultTable.DefaultTable): glyphletOffsets[i] = pos glyphletArray = array.array("I", glyphletOffsets) if sys.byteorder != "big": glyphletArray.byteswap() - dataList.append(glyphletArray.tostring()) + dataList.append(glyphletArray.tobytes()) dataList += self.GMAPs dataList += self.glyphlets data = bytesjoin(dataList) diff --git a/Lib/fontTools/ttLib/tables/G__l_o_c.py b/Lib/fontTools/ttLib/tables/G__l_o_c.py index 3a196fec0..4ff8a47b5 100644 --- a/Lib/fontTools/ttLib/tables/G__l_o_c.py +++ b/Lib/fontTools/ttLib/tables/G__l_o_c.py @@ -42,11 +42,11 @@ class table_G__l_o_c(DefaultTable.DefaultTable): flags=(bool(self.attribIds) << 1) + (self.locations.typecode == 'I'), numAttribs=self.numAttribs)) if sys.byteorder != "big": self.locations.byteswap() - data += self.locations.tostring() + data += self.locations.tobytes() if sys.byteorder != "big": self.locations.byteswap() if self.attribIds: if sys.byteorder != "big": self.attribIds.byteswap() - data += self.attribIds.tostring() + data += self.attribIds.tobytes() if sys.byteorder != "big": self.attribIds.byteswap() return data diff --git a/Lib/fontTools/ttLib/tables/L_T_S_H_.py b/Lib/fontTools/ttLib/tables/L_T_S_H_.py index 54a7ce829..689548b9b 100644 --- a/Lib/fontTools/ttLib/tables/L_T_S_H_.py +++ b/Lib/fontTools/ttLib/tables/L_T_S_H_.py @@ -33,7 +33,7 @@ class table_L_T_S_H_(DefaultTable.DefaultTable): for name in names: yPels[ttFont.getGlyphID(name)] = self.yPels[name] yPels = array.array("B", yPels) - return struct.pack(">HH", version, numGlyphs) + yPels.tostring() + return struct.pack(">HH", version, numGlyphs) + yPels.tobytes() def toXML(self, writer, ttFont): names = sorted(self.yPels.keys()) diff --git a/Lib/fontTools/ttLib/tables/S__i_l_f.py b/Lib/fontTools/ttLib/tables/S__i_l_f.py index 2359942de..b10692b0e 100644 --- a/Lib/fontTools/ttLib/tables/S__i_l_f.py +++ b/Lib/fontTools/ttLib/tables/S__i_l_f.py @@ -745,7 +745,7 @@ class Pass(object): transes = [] for t in self.stateTrans: if sys.byteorder != "big": t.byteswap() - transes.append(t.tostring()) + transes.append(t.tobytes()) if sys.byteorder != "big": t.byteswap() if not len(transes): self.startStates = [0] diff --git a/Lib/fontTools/ttLib/tables/T_S_I__5.py b/Lib/fontTools/ttLib/tables/T_S_I__5.py index cf0794229..5c7da1cb4 100644 --- a/Lib/fontTools/ttLib/tables/T_S_I__5.py +++ b/Lib/fontTools/ttLib/tables/T_S_I__5.py @@ -28,7 +28,7 @@ class table_T_S_I__5(DefaultTable.DefaultTable): for i in range(len(glyphNames)): a.append(self.glyphGrouping.get(glyphNames[i], 0)) if sys.byteorder != "big": a.byteswap() - return a.tostring() + return a.tobytes() def toXML(self, writer, ttFont): names = sorted(self.glyphGrouping.keys()) diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py index b69afc7ef..2fdc8c38a 100644 --- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py +++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py @@ -266,7 +266,7 @@ class cmap_format_0(CmapSubtable): valueList = [getGlyphID(cmap[i]) if i in cmap else 0 for i in range(256)] gids = array.array("B", valueList) - data = struct.pack(">HHH", 0, 262, self.language) + gids.tostring() + data = struct.pack(">HHH", 0, 262, self.language) + gids.tobytes() assert len(data) == 262 return data @@ -826,7 +826,7 @@ class cmap_format_4(CmapSubtable): if sys.byteorder != "big": charCodeArray.byteswap() if sys.byteorder != "big": idDeltaArray.byteswap() if sys.byteorder != "big": restArray.byteswap() - data = charCodeArray.tostring() + idDeltaArray.tostring() + restArray.tostring() + data = charCodeArray.tobytes() + idDeltaArray.tobytes() + restArray.tobytes() length = struct.calcsize(cmap_format_4_format) + len(data) header = struct.pack(cmap_format_4_format, self.format, length, self.language, @@ -885,7 +885,7 @@ class cmap_format_6(CmapSubtable): ] gids = array.array("H", valueList) if sys.byteorder != "big": gids.byteswap() - data = gids.tostring() + data = gids.tobytes() else: data = b"" firstCode = 0 diff --git a/Lib/fontTools/ttLib/tables/_c_v_t.py b/Lib/fontTools/ttLib/tables/_c_v_t.py index eab23fe3d..0016e3bb9 100644 --- a/Lib/fontTools/ttLib/tables/_c_v_t.py +++ b/Lib/fontTools/ttLib/tables/_c_v_t.py @@ -15,7 +15,7 @@ class table__c_v_t(DefaultTable.DefaultTable): def compile(self, ttFont): values = self.values[:] if sys.byteorder != "big": values.byteswap() - return values.tostring() + return values.tobytes() def toXML(self, writer, ttFont): for i in range(len(self.values)): diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index dfad241a5..d22322c75 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -795,7 +795,7 @@ class Glyph(object): data = [] endPtsOfContours = array.array("h", self.endPtsOfContours) if sys.byteorder != "big": endPtsOfContours.byteswap() - data.append(endPtsOfContours.tostring()) + data.append(endPtsOfContours.tobytes()) instructions = self.program.getBytecode() data.append(struct.pack(">h", len(instructions))) data.append(instructions) @@ -859,7 +859,7 @@ class Glyph(object): repeat = 0 compressedflags.append(flag) lastflag = flag - compressedFlags = array.array("B", compressedflags).tostring() + compressedFlags = array.array("B", compressedflags).tobytes() compressedXs = bytesjoin(xPoints) compressedYs = bytesjoin(yPoints) return (compressedFlags, compressedXs, compressedYs) @@ -914,9 +914,9 @@ class Glyph(object): raise Exception("internal error") except StopIteration: pass - compressedFlags = compressedFlags.tostring() - compressedXs = compressedXs.tostring() - compressedYs = compressedYs.tostring() + compressedFlags = compressedFlags.tobytes() + compressedXs = compressedXs.tobytes() + compressedYs = compressedYs.tobytes() return (compressedFlags, compressedXs, compressedYs) @@ -1156,7 +1156,7 @@ class Glyph(object): # Remove padding data = data[:i] - self.data = data.tostring() + self.data = data.tobytes() def removeHinting(self): self.trim (remove_hinting=True) diff --git a/Lib/fontTools/ttLib/tables/_g_v_a_r.py b/Lib/fontTools/ttLib/tables/_g_v_a_r.py index d3f4a9d3d..cd323f657 100644 --- a/Lib/fontTools/ttLib/tables/_g_v_a_r.py +++ b/Lib/fontTools/ttLib/tables/_g_v_a_r.py @@ -158,7 +158,7 @@ class table__g_v_a_r(DefaultTable.DefaultTable): packed = array.array("I", offsets) tableFormat = 1 if sys.byteorder != "big": packed.byteswap() - return (packed.tostring(), tableFormat) + return (packed.tobytes(), tableFormat) def toXML(self, writer, ttFont): writer.simpletag("version", value=self.version) diff --git a/Lib/fontTools/ttLib/tables/_h_m_t_x.py b/Lib/fontTools/ttLib/tables/_h_m_t_x.py index 56b2913de..a690a6e6e 100644 --- a/Lib/fontTools/ttLib/tables/_h_m_t_x.py +++ b/Lib/fontTools/ttLib/tables/_h_m_t_x.py @@ -108,7 +108,7 @@ class table__h_m_t_x(DefaultTable.DefaultTable): raise additionalMetrics = array.array("h", additionalMetrics) if sys.byteorder != "big": additionalMetrics.byteswap() - data = data + additionalMetrics.tostring() + data = data + additionalMetrics.tobytes() return data def toXML(self, writer, ttFont): diff --git a/Lib/fontTools/ttLib/tables/_l_o_c_a.py b/Lib/fontTools/ttLib/tables/_l_o_c_a.py index 20ecbfff9..df61fafd2 100644 --- a/Lib/fontTools/ttLib/tables/_l_o_c_a.py +++ b/Lib/fontTools/ttLib/tables/_l_o_c_a.py @@ -46,7 +46,7 @@ class table__l_o_c_a(DefaultTable.DefaultTable): locations = array.array("I", self.locations) ttFont['head'].indexToLocFormat = 1 if sys.byteorder != "big": locations.byteswap() - return locations.tostring() + return locations.tobytes() def set(self, locations): self.locations = array.array("I", locations) diff --git a/Lib/fontTools/ttLib/tables/_p_o_s_t.py b/Lib/fontTools/ttLib/tables/_p_o_s_t.py index 503695bc1..3dd3b77cf 100644 --- a/Lib/fontTools/ttLib/tables/_p_o_s_t.py +++ b/Lib/fontTools/ttLib/tables/_p_o_s_t.py @@ -171,7 +171,7 @@ class table__p_o_s_t(DefaultTable.DefaultTable): extraNames.append(psName) indices.append(index) if sys.byteorder != "big": indices.byteswap() - return struct.pack(">H", numGlyphs) + indices.tostring() + packPStrings(extraNames) + return struct.pack(">H", numGlyphs) + indices.tobytes() + packPStrings(extraNames) def encode_format_4_0(self, ttFont): from fontTools import agl @@ -188,7 +188,7 @@ class table__p_o_s_t(DefaultTable.DefaultTable): else: indices.append(0xFFFF) if sys.byteorder != "big": indices.byteswap() - return indices.tostring() + return indices.tobytes() def toXML(self, writer, ttFont): formatstring, names, fixes = sstruct.getformat(postFormat) diff --git a/Lib/fontTools/ttLib/tables/ttProgram.py b/Lib/fontTools/ttLib/tables/ttProgram.py index 80a07acc3..3094d62bc 100644 --- a/Lib/fontTools/ttLib/tables/ttProgram.py +++ b/Lib/fontTools/ttLib/tables/ttProgram.py @@ -222,7 +222,7 @@ class Program(object): def getBytecode(self): if not hasattr(self, "bytecode"): self._assemble() - return self.bytecode.tostring() + return self.bytecode.tobytes() def getAssembly(self, preserve=True): if not hasattr(self, "assembly"): diff --git a/Lib/fontTools/ttLib/woff2.py b/Lib/fontTools/ttLib/woff2.py index 755b3e604..0448546fd 100644 --- a/Lib/fontTools/ttLib/woff2.py +++ b/Lib/fontTools/ttLib/woff2.py @@ -651,7 +651,7 @@ class WOFF2LocaTable(getTableClass('loca')): else: locations = array.array("I", self.locations) if sys.byteorder != "big": locations.byteswap() - data = locations.tostring() + data = locations.tobytes() else: # use the most compact indexFormat given the current glyph offsets data = super(WOFF2LocaTable, self).compile(ttFont) @@ -733,7 +733,7 @@ class WOFF2GlyfTable(getTableClass('glyf')): for glyphID in range(self.numGlyphs): self._encodeGlyph(glyphID) - self.bboxStream = self.bboxBitmap.tostring() + self.bboxStream + self.bboxStream = self.bboxBitmap.tobytes() + self.bboxStream for stream in self.subStreams: setattr(self, stream + 'Size', len(getattr(self, stream))) self.version = 0 @@ -961,8 +961,8 @@ class WOFF2GlyfTable(getTableClass('glyf')): triplets.append(absY >> 8) triplets.append(absY & 0xff) - self.flagStream += flags.tostring() - self.glyphStream += triplets.tostring() + self.flagStream += flags.tobytes() + self.glyphStream += triplets.tobytes() class WOFF2HmtxTable(getTableClass("hmtx")): @@ -1093,7 +1093,7 @@ class WOFF2HmtxTable(getTableClass("hmtx")): ) if sys.byteorder != "big": advanceWidthArray.byteswap() - data += advanceWidthArray.tostring() + data += advanceWidthArray.tobytes() if hasLsbArray: lsbArray = array.array( @@ -1106,7 +1106,7 @@ class WOFF2HmtxTable(getTableClass("hmtx")): ) if sys.byteorder != "big": lsbArray.byteswap() - data += lsbArray.tostring() + data += lsbArray.tobytes() if hasLeftSideBearingArray: leftSideBearingArray = array.array( @@ -1118,7 +1118,7 @@ class WOFF2HmtxTable(getTableClass("hmtx")): ) if sys.byteorder != "big": leftSideBearingArray.byteswap() - data += leftSideBearingArray.tostring() + data += leftSideBearingArray.tobytes() return data