2to3 --fix=print with manual fixup
diff --git a/Lib/fontTools/afmLib.py b/Lib/fontTools/afmLib.py
index e98a59f..da6c9f5 100644
--- a/Lib/fontTools/afmLib.py
+++ b/Lib/fontTools/afmLib.py
@@ -369,16 +369,16 @@
afm = AFM(path)
char = 'A'
if afm.has_char(char):
- print afm[char] # print charnum, width and boundingbox
+ print(afm[char]) # print charnum, width and boundingbox
pair = ('A', 'V')
if afm.has_kernpair(pair):
- print afm[pair] # print kerning value for pair
- print afm.Version # various other afm entries have become attributes
- print afm.Weight
+ print(afm[pair]) # print kerning value for pair
+ print(afm.Version) # various other afm entries have become attributes
+ print(afm.Weight)
# afm.comments() returns a list of all Comment lines found in the AFM
- print afm.comments()
+ print(afm.comments())
#print afm.chars()
#print afm.kernpairs()
- print afm
+ print(afm)
afm.write(path + ".muck")
diff --git a/Lib/fontTools/cffLib.py b/Lib/fontTools/cffLib.py
index c0c6da9..d0c35f2 100644
--- a/Lib/fontTools/cffLib.py
+++ b/Lib/fontTools/cffLib.py
@@ -138,7 +138,7 @@
count = 1
while True:
if DEBUG:
- print "CFFWriter.toFile() iteration:", count
+ print("CFFWriter.toFile() iteration:", count)
count = count + 1
pos = 0
posList = [pos]
@@ -155,7 +155,7 @@
break
lastPosList = posList
if DEBUG:
- print "CFFWriter.toFile() writing to file."
+ print("CFFWriter.toFile() writing to file.")
begin = file.tell()
posList = [0]
for item in self.data:
@@ -314,7 +314,7 @@
self.items = []
return
if DEBUG:
- print "loading %s at %s" % (name, file.tell())
+ print("loading %s at %s" % (name, file.tell()))
self.file = file
count = readCard16(file)
self.count = count
@@ -324,7 +324,7 @@
return
offSize = readCard8(file)
if DEBUG:
- print " index count: %s offSize: %s" % (count, offSize)
+ print(" index count: %s offSize: %s" % (count, offSize))
assert offSize <= 4, "offSize too large: %s" % offSize
self.offsets = offsets = []
pad = '\0' * (4 - offSize)
@@ -336,7 +336,7 @@
self.offsetBase = file.tell() - 1
file.seek(self.offsetBase + offsets[-1]) # pretend we've read the whole lot
if DEBUG:
- print " end of %s at %s" % (name, file.tell())
+ print(" end of %s at %s" % (name, file.tell()))
def __len__(self):
return len(self.items)
@@ -778,7 +778,7 @@
file = parent.file
file.seek(value)
if DEBUG:
- print "loading charset at %s" % value
+ print("loading charset at %s" % value)
format = readCard8(file)
if format == 0:
charset = parseCharset0(numGlyphs, file, parent.strings, isCID)
@@ -788,7 +788,7 @@
raise NotImplementedError
assert len(charset) == numGlyphs
if DEBUG:
- print " charset end at %s" % file.tell()
+ print(" charset end at %s" % file.tell())
else: # offset == 0 -> no charset data.
if isCID or "CharStrings" not in parent.rawDict:
assert value == 0 # We get here only when processing fontDicts from the FDArray of CFF-CID fonts. Only the real topDict references the chrset.
@@ -957,7 +957,7 @@
file = parent.file
file.seek(value)
if DEBUG:
- print "loading Encoding at %s" % value
+ print("loading Encoding at %s" % value)
format = readCard8(file)
haveSupplement = format & 0x80
if haveSupplement:
@@ -1329,8 +1329,8 @@
def compile(self, reason):
if DEBUG:
- print "-- compiling %s for %s" % (self.__class__.__name__, reason)
- print "in baseDict: ", self
+ print("-- compiling %s for %s" % (self.__class__.__name__, reason))
+ print("in baseDict: ", self)
rawDict = self.rawDict
data = []
for name in self.dictObj.order:
@@ -1463,7 +1463,7 @@
def __init__(self, strings=None, file=None, offset=None):
self.rawDict = {}
if DEBUG:
- print "loading %s at %s" % (self.__class__.__name__, offset)
+ print("loading %s at %s" % (self.__class__.__name__, offset))
self.file = file
self.offset = offset
self.strings = strings
@@ -1471,7 +1471,7 @@
def decompile(self, data):
if DEBUG:
- print " length %s is %s" % (self.__class__.__name__, len(data))
+ print(" length %s is %s" % (self.__class__.__name__, len(data)))
dec = self.decompilerClass(self.strings)
dec.decompile(data)
self.rawDict = dec.getDict()
@@ -1552,7 +1552,7 @@
try:
charString.decompile()
except:
- print "Error in charstring ", i
+ print("Error in charstring ", i)
import sys
type, value = sys. exc_info()[0:2]
raise type(value)
diff --git a/Lib/fontTools/fondLib.py b/Lib/fontTools/fondLib.py
index b4ae0b8..6af0d34 100644
--- a/Lib/fontTools/fondLib.py
+++ b/Lib/fontTools/fondLib.py
@@ -143,9 +143,9 @@
header = header + struct.pack(*(">hh",) + self.ffIntl)
header = header + struct.pack(">h", self.ffVersion)
if DEBUG:
- print "header is the same?", self._rawheader == header and 'yes.' or 'no.'
+ print("header is the same?", self._rawheader == header and 'yes.' or 'no.')
if self._rawheader != header:
- print len(self._rawheader), len(header)
+ print(len(self._rawheader), len(header))
self._rawheader = header
def _getfontassociationtable(self):
@@ -169,9 +169,9 @@
data = data + struct.pack(">3h", size, stype, ID)
if DEBUG:
- print "font association table is the same?", self._rawfontassociationtable == data and 'yes.' or 'no.'
+ print("font association table is the same?", self._rawfontassociationtable == data and 'yes.' or 'no.')
if self._rawfontassociationtable != data:
- print len(self._rawfontassociationtable), len(data)
+ print(len(self._rawfontassociationtable), len(data))
self._rawfontassociationtable = data
def _getoffsettable(self):
@@ -248,7 +248,7 @@
for width in table:
data = data + struct.pack('>h', width)
if DEBUG:
- print "glyph width table is the same?", self._rawglyphwidthtable == data and 'yes.' or 'no.'
+ print("glyph width table is the same?", self._rawglyphwidthtable == data and 'yes.' or 'no.')
self._rawglyphwidthtable = data
def _getkerningtables(self):
@@ -292,9 +292,9 @@
data = string.join(data, '')
if DEBUG:
- print "kerning table is the same?", self._rawkerningtables == data and 'yes.' or 'no.'
+ print("kerning table is the same?", self._rawkerningtables == data and 'yes.' or 'no.')
if self._rawkerningtables != data:
- print len(self._rawkerningtables), len(data)
+ print(len(self._rawkerningtables), len(data))
self._rawkerningtables = data
def _getstylemappingtable(self):
@@ -345,7 +345,7 @@
data = data + '\0'
if DEBUG:
- print "style mapping table is the same?", self._rawstylemappingtable == data and 'yes.' or 'no.'
+ print("style mapping table is the same?", self._rawstylemappingtable == data and 'yes.' or 'no.')
self._rawstylemappingtable = data
def _unpackstylestrings(self):
diff --git a/Lib/fontTools/misc/bezierTools.py b/Lib/fontTools/misc/bezierTools.py
index d15e070..d8c70b0 100644
--- a/Lib/fontTools/misc/bezierTools.py
+++ b/Lib/fontTools/misc/bezierTools.py
@@ -400,7 +400,7 @@
segments on a single line as a tuple.
"""
for segment in segments:
- print _segmentrepr(segment)
+ print(_segmentrepr(segment))
if __name__ == "__main__":
import doctest
diff --git a/Lib/fontTools/misc/eexec.py b/Lib/fontTools/misc/eexec.py
index fbe2bd3..84e3b31 100644
--- a/Lib/fontTools/misc/eexec.py
+++ b/Lib/fontTools/misc/eexec.py
@@ -56,10 +56,10 @@
def _test():
import fontTools.misc.eexecOp as eexecOp
testStr = "\0\0asdadads asds\265"
- print decrypt, decrypt(testStr, 12321)
- print eexecOp.decrypt, eexecOp.decrypt(testStr, 12321)
- print encrypt, encrypt(testStr, 12321)
- print eexecOp.encrypt, eexecOp.encrypt(testStr, 12321)
+ print(decrypt, decrypt(testStr, 12321))
+ print(eexecOp.decrypt, eexecOp.decrypt(testStr, 12321))
+ print(encrypt, encrypt(testStr, 12321))
+ print(eexecOp.encrypt, eexecOp.encrypt(testStr, 12321))
if __name__ == "__main__":
diff --git a/Lib/fontTools/misc/homeResFile.py b/Lib/fontTools/misc/homeResFile.py
index 2bdf1e4..4c2c85b 100644
--- a/Lib/fontTools/misc/homeResFile.py
+++ b/Lib/fontTools/misc/homeResFile.py
@@ -91,4 +91,4 @@
if __name__ == "__main__":
fond = Res.GetNamedResource("FOND", "Helvetica")
- print HomeResFile(fond)
+ print(HomeResFile(fond))
diff --git a/Lib/fontTools/misc/psCharStrings.py b/Lib/fontTools/misc/psCharStrings.py
index 275c171..162b1e3 100644
--- a/Lib/fontTools/misc/psCharStrings.py
+++ b/Lib/fontTools/misc/psCharStrings.py
@@ -304,7 +304,7 @@
try:
bytecode = "".join(bytecode)
except TypeError:
- print bytecode
+ print(bytecode)
raise
self.setBytecode(bytecode)
diff --git a/Lib/fontTools/misc/sstruct.py b/Lib/fontTools/misc/sstruct.py
index 03681da..b5b7595 100644
--- a/Lib/fontTools/misc/sstruct.py
+++ b/Lib/fontTools/misc/sstruct.py
@@ -177,7 +177,7 @@
afixed: 16.16F
"""
- print 'size:', calcsize(format)
+ print('size:', calcsize(format))
class foo:
pass
@@ -194,11 +194,11 @@
i.afixed = 1.5
data = pack(format, i)
- print 'data:', repr(data)
- print unpack(format, data)
+ print('data:', repr(data))
+ print(unpack(format, data))
i2 = foo()
unpack(format, data, i2)
- print vars(i2)
+ print(vars(i2))
if __name__ == "__main__":
_test()
diff --git a/Lib/fontTools/misc/xmlReader.py b/Lib/fontTools/misc/xmlReader.py
index 6dd1e27..4ce302e 100644
--- a/Lib/fontTools/misc/xmlReader.py
+++ b/Lib/fontTools/misc/xmlReader.py
@@ -75,7 +75,7 @@
ttLib.debugmsg(msg)
else:
if not self.quiet:
- print msg
+ print(msg)
if tag == "GlyphOrder":
tableClass = ttLib.GlyphOrder
elif "ERROR" in attrs:
@@ -118,7 +118,7 @@
class ProgressPrinter:
def __init__(self, title, maxval=100):
- print title
+ print(title)
def set(self, val, maxval=None):
pass
@@ -127,5 +127,5 @@
pass
def setLabel(self, text):
- print text
+ print(text)
diff --git a/Lib/fontTools/nfntLib.py b/Lib/fontTools/nfntLib.py
index be032f1..5e25c1b 100644
--- a/Lib/fontTools/nfntLib.py
+++ b/Lib/fontTools/nfntLib.py
@@ -301,4 +301,4 @@
font.unpackGlyphs()
font.packGlyphs()
data2 = font.compile()
- print "xxxxx", data == data2, len(data) == len(data2)
+ print("xxxxx", data == data2, len(data) == len(data2))
diff --git a/Lib/fontTools/pens/basePen.py b/Lib/fontTools/pens/basePen.py
index b97ec60..4f7daf2 100644
--- a/Lib/fontTools/pens/basePen.py
+++ b/Lib/fontTools/pens/basePen.py
@@ -339,14 +339,14 @@
class _TestPen(BasePen):
"""Test class that prints PostScript to stdout."""
def _moveTo(self, pt):
- print "%s %s moveto" % (pt[0], pt[1])
+ print("%s %s moveto" % (pt[0], pt[1]))
def _lineTo(self, pt):
- print "%s %s lineto" % (pt[0], pt[1])
+ print("%s %s lineto" % (pt[0], pt[1]))
def _curveToOne(self, bcp1, bcp2, pt):
- print "%s %s %s %s %s %s curveto" % (bcp1[0], bcp1[1],
- bcp2[0], bcp2[1], pt[0], pt[1])
+ print("%s %s %s %s %s %s curveto" % (bcp1[0], bcp1[1],
+ bcp2[0], bcp2[1], pt[0], pt[1]))
def _closePath(self):
- print "closepath"
+ print("closepath")
if __name__ == "__main__":
diff --git a/Lib/fontTools/pens/boundsPen.py b/Lib/fontTools/pens/boundsPen.py
index 3fde6e3..ffe2251 100644
--- a/Lib/fontTools/pens/boundsPen.py
+++ b/Lib/fontTools/pens/boundsPen.py
@@ -86,8 +86,8 @@
pen = ControlBoundsPen(None)
draw(pen)
- print pen.bounds
+ print(pen.bounds)
pen = BoundsPen(None)
draw(pen)
- print pen.bounds
+ print(pen.bounds)
diff --git a/Lib/fontTools/pens/reportLabPen.py b/Lib/fontTools/pens/reportLabPen.py
index d30c905..3393298 100644
--- a/Lib/fontTools/pens/reportLabPen.py
+++ b/Lib/fontTools/pens/reportLabPen.py
@@ -33,10 +33,10 @@
if __name__=="__main__":
import sys
if len(sys.argv) < 3:
- print "Usage: reportLabPen.py <OTF/TTF font> <glyphname> [<image file to create>]"
- print " If no image file name is created, by default <glyphname>.png is created."
- print " example: reportLabPen.py Arial.TTF R test.png"
- print " (The file format will be PNG, regardless of the image file name supplied)"
+ print("Usage: reportLabPen.py <OTF/TTF font> <glyphname> [<image file to create>]")
+ print(" If no image file name is created, by default <glyphname>.png is created.")
+ print(" example: reportLabPen.py Arial.TTF R test.png")
+ print(" (The file format will be PNG, regardless of the image file name supplied)")
sys.exit(0)
from fontTools.ttLib import TTFont
diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py
index 198d750..b68624d 100644
--- a/Lib/fontTools/ttLib/__init__.py
+++ b/Lib/fontTools/ttLib/__init__.py
@@ -301,7 +301,7 @@
debugmsg(report)
else:
if not quiet:
- print report
+ print(report)
if tag not in self:
return
xmlTag = tagToXML(tag)
@@ -390,7 +390,7 @@
if not self.ignoreDecompileErrors:
raise
# fall back to DefaultTable, retaining the binary table data
- print "An exception occurred during the decompilation of the '%s' table" % tag
+ print("An exception occurred during the decompilation of the '%s' table" % tag)
from .tables.DefaultTable import DefaultTable
import StringIO
file = StringIO.StringIO()
@@ -896,7 +896,7 @@
def debugmsg(msg):
import time
- print msg + time.strftime(" (%H:%M:%S)", time.localtime(time.time()))
+ print(msg + time.strftime(" (%H:%M:%S)", time.localtime(time.time())))
# Table order as recommended in the OpenType specification 1.4
diff --git a/Lib/fontTools/ttLib/sfnt.py b/Lib/fontTools/ttLib/sfnt.py
index 2248236..d69b7b7 100644
--- a/Lib/fontTools/ttLib/sfnt.py
+++ b/Lib/fontTools/ttLib/sfnt.py
@@ -90,7 +90,7 @@
assert checksum == entry.checksum, "bad checksum for '%s' table" % tag
elif checksum != entry.checkSum:
# Be friendly, and just print a warning.
- print "bad checksum for '%s' table" % tag
+ print("bad checksum for '%s' table" % tag)
return data
def __delitem__(self, tag):
diff --git a/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py b/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py
index 4aeaf4b..f5d0f02 100644
--- a/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py
+++ b/Lib/fontTools/ttLib/tables/BitmapGlyphMetrics.py
@@ -47,7 +47,7 @@
if name in metricNames:
vars(self)[name] = safeEval(attrs['value'])
else:
- print "Warning: unknown name '%s' being ignored in %s." % name, self.__class__.__name__
+ print("Warning: unknown name '%s' being ignored in %s." % name, self.__class__.__name__)
class BigGlyphMetrics(BitmapGlyphMetrics):
diff --git a/Lib/fontTools/ttLib/tables/E_B_D_T_.py b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
index 1563b98..2a1a0d8 100644
--- a/Lib/fontTools/ttLib/tables/E_B_D_T_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_D_T_.py
@@ -167,7 +167,7 @@
assert glyphName not in bitmapGlyphDict, "Duplicate glyphs with the same name '%s' in the same strike." % glyphName
bitmapGlyphDict[glyphName] = curGlyph
else:
- print "Warning: %s being ignored by %s", name, self.__class__.__name__
+ print("Warning: %s being ignored by %s", name, self.__class__.__name__)
# Grow the strike data array to the appropriate size. The XML
# format allows the strike index value to be out of order.
@@ -197,7 +197,7 @@
if name in componentNames:
vars(self)[name] = safeEval(attrs['value'])
else:
- print "Warning: unknown name '%s' being ignored by EbdtComponent." % name
+ print("Warning: unknown name '%s' being ignored by EbdtComponent." % name)
# Helper functions for dealing with binary.
@@ -471,7 +471,7 @@
self.metrics = metricsClass()
self.metrics.fromXML(name, attrs, content, ttFont)
elif name == oppositeMetricsName:
- print "Warning: %s being ignored in format %d." % oppositeMetricsName, self.getFormat()
+ print("Warning: %s being ignored in format %d." % oppositeMetricsName, self.getFormat())
return BitmapPlusMetricsMixin
@@ -685,7 +685,7 @@
curComponent.fromXML(name, attrs, content, ttFont)
self.componentArray.append(curComponent)
else:
- print "Warning: '%s' being ignored in component array." % name
+ print("Warning: '%s' being ignored in component array." % name)
class ebdt_bitmap_format_8(BitmapPlusSmallMetricsMixin, ComponentBitmapGlyph):
diff --git a/Lib/fontTools/ttLib/tables/E_B_L_C_.py b/Lib/fontTools/ttLib/tables/E_B_L_C_.py
index 9371568..d2fc80a 100644
--- a/Lib/fontTools/ttLib/tables/E_B_L_C_.py
+++ b/Lib/fontTools/ttLib/tables/E_B_L_C_.py
@@ -294,7 +294,7 @@
elif name in dataNames:
vars(self)[name] = safeEval(attrs['value'])
else:
- print "Warning: unknown name '%s' being ignored in BitmapSizeTable." % name
+ print("Warning: unknown name '%s' being ignored in BitmapSizeTable." % name)
class SbitLineMetrics:
@@ -503,7 +503,7 @@
self.metrics = BigGlyphMetrics()
self.metrics.fromXML(name, attrs, content, ttFont)
elif name == SmallGlyphMetrics.__name__:
- print "Warning: SmallGlyphMetrics being ignored in format %d." % self.indexFormat
+ print("Warning: SmallGlyphMetrics being ignored in format %d." % self.indexFormat)
def padBitmapData(self, data):
# Make sure that the data isn't bigger than the fixed size.
diff --git a/Lib/fontTools/ttLib/tables/S_V_G_.py b/Lib/fontTools/ttLib/tables/S_V_G_.py
index 97d0b82..3b68b35 100644
--- a/Lib/fontTools/ttLib/tables/S_V_G_.py
+++ b/Lib/fontTools/ttLib/tables/S_V_G_.py
@@ -105,7 +105,7 @@
self.decompile_format_1(data, ttFont)
else:
if self.version != 0:
- print "Unknown SVG table version '%s'. Decompiling as version 0." % (self.version)
+ print("Unknown SVG table version '%s'. Decompiling as version 0." % (self.version))
self.decompile_format_0(data, ttFont)
@@ -306,7 +306,7 @@
if self.colorPalettes.numColorParams == 0:
self.colorPalettes = None
else:
- print "Unknown", name, content
+ print("Unknown", name, content)
class DocumentIndexEntry:
def __init__(self):
diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
index 5a0679b..1a0a0cd 100644
--- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py
+++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
@@ -33,7 +33,7 @@
format, length = struct.unpack(">HL", data[offset:offset+6])
if not length:
- print "Error: cmap subtable is reported as having zero length: platformID %s, platEncID %s, format %s offset %s. Skipping table." % (platformID, platEncID,format, offset)
+ print("Error: cmap subtable is reported as having zero length: platformID %s, platEncID %s, format %s offset %s. Skipping table." % (platformID, platEncID,format, offset))
continue
if format not in cmap_classes:
table = cmap_format_unknown(format)
diff --git a/Lib/fontTools/ttLib/tables/_m_a_x_p.py b/Lib/fontTools/ttLib/tables/_m_a_x_p.py
index 737af07..de6a29c 100644
--- a/Lib/fontTools/ttLib/tables/_m_a_x_p.py
+++ b/Lib/fontTools/ttLib/tables/_m_a_x_p.py
@@ -113,10 +113,10 @@
def testrepr(self):
items = sorted(self.__dict__.items())
- print ". . . . . . . . ."
+ print(". . . . . . . . .")
for combo in items:
- print " %s: %s" % combo
- print ". . . . . . . . ."
+ print(" %s: %s" % combo)
+ print(". . . . . . . . .")
def toXML(self, writer, ttFont):
if self.tableVersion != 0x00005000:
diff --git a/Lib/fontTools/ttLib/tables/_n_a_m_e.py b/Lib/fontTools/ttLib/tables/_n_a_m_e.py
index b1ef1f4..aa5f966 100644
--- a/Lib/fontTools/ttLib/tables/_n_a_m_e.py
+++ b/Lib/fontTools/ttLib/tables/_n_a_m_e.py
@@ -25,8 +25,7 @@
expectedStringOffset = 6 + n * nameRecordSize
if stringOffset != expectedStringOffset:
# XXX we need a warn function
- print "Warning: 'name' table stringOffset incorrect.",
- print "Expected: %s; Actual: %s" % (expectedStringOffset, stringOffset)
+ print("Warning: 'name' table stringOffset incorrect. Expected: %s; Actual: %s" % (expectedStringOffset, stringOffset))
stringData = data[stringOffset:]
data = data[6:]
self.names = []
diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py
index cac8a40..98bc2d4 100644
--- a/Lib/fontTools/ttLib/tables/otBase.py
+++ b/Lib/fontTools/ttLib/tables/otBase.py
@@ -45,12 +45,12 @@
if cachingStats:
stats = sorted([(v, k) for k, v in cachingStats.items()])
stats.reverse()
- print "cachingsstats for ", self.tableTag
+ print("cachingsstats for ", self.tableTag)
for v, k in stats:
if v < 2:
break
- print v, k
- print "---", len(stats)
+ print(v, k)
+ print("---", len(stats))
def compile(self, font):
""" Create a top-level OTFWriter for the GPOS/GSUB table.
diff --git a/Lib/fontTools/ttLib/tables/otConverters.py b/Lib/fontTools/ttLib/tables/otConverters.py
index 03a1a1f..b587022 100644
--- a/Lib/fontTools/ttLib/tables/otConverters.py
+++ b/Lib/fontTools/ttLib/tables/otConverters.py
@@ -225,8 +225,8 @@
return None
if offset <= 3:
# XXX hack to work around buggy pala.ttf
- print "*** Warning: offset is not 0, yet suspiciously low (%s). table: %s" \
- % (offset, self.tableClass.__name__)
+ print("*** Warning: offset is not 0, yet suspiciously low (%s). table: %s" \
+ % (offset, self.tableClass.__name__))
return None
table = self.tableClass()
table.reader = reader.getSubReader(offset)
diff --git a/Lib/fontTools/ttLib/tables/ttProgram.py b/Lib/fontTools/ttLib/tables/ttProgram.py
index 92dd0e2..5996b5c 100644
--- a/Lib/fontTools/ttLib/tables/ttProgram.py
+++ b/Lib/fontTools/ttLib/tables/ttProgram.py
@@ -406,5 +406,5 @@
p.fromBytecode(bc)
asm = p.getAssembly()
p.fromAssembly(asm)
- print bc == p.getBytecode()
+ print(bc == p.getBytecode())
diff --git a/Lib/fontTools/ttx.py b/Lib/fontTools/ttx.py
index cd42084..f235fcc 100644
--- a/Lib/fontTools/ttx.py
+++ b/Lib/fontTools/ttx.py
@@ -77,7 +77,7 @@
from fontTools import version
def usage():
- print __doc__ % version
+ print(__doc__ % version)
sys.exit(2)
@@ -120,11 +120,11 @@
for option, value in rawOptions:
# general options
if option == "-h":
- print __doc__ % version
+ print(__doc__ % version)
sys.exit(0)
elif option == "-d":
if not os.path.isdir(value):
- print "The -d option value must be an existing directory"
+ print("The -d option value must be an existing directory")
sys.exit(2)
self.outputDir = value
elif option == "-o":
@@ -147,7 +147,7 @@
elif option == "-z":
validOptions = ('raw', 'row', 'bitwise', 'extfile')
if value not in validOptions:
- print "-z does not allow %s as a format. Use %s" % (option, validOptions)
+ print("-z does not allow %s as a format. Use %s" % (option, validOptions))
sys.exit(2)
self.bitmapGlyphDataFormat = value
elif option == "-y":
@@ -162,10 +162,10 @@
elif option == "-e":
self.ignoreDecompileErrors = False
if self.onlyTables and self.skipTables:
- print "-t and -x options are mutually exclusive"
+ print("-t and -x options are mutually exclusive")
sys.exit(2)
if self.mergeFile and numFiles > 1:
- print "Must specify exactly one TTX source file when using -m"
+ print("Must specify exactly one TTX source file when using -m")
sys.exit(2)
@@ -174,24 +174,24 @@
ttf = TTFont(input, fontNumber=options.fontNumber, lazy=True)
reader = ttf.reader
tags = sorted(reader.keys())
- print 'Listing table info for "%s":' % input
+ print('Listing table info for "%s":' % input)
format = " %4s %10s %7s %7s"
- print format % ("tag ", " checksum", " length", " offset")
- print format % ("----", "----------", "-------", "-------")
+ print(format % ("tag ", " checksum", " length", " offset"))
+ print(format % ("----", "----------", "-------", "-------"))
for tag in tags:
entry = reader.tables[tag]
checkSum = int(entry.checkSum)
if checkSum < 0:
checkSum = checkSum + 0x100000000
checksum = "0x" + string.zfill(hex(checkSum)[2:-1], 8)
- print format % (tag, checksum, entry.length, entry.offset)
- print
+ print(format % (tag, checksum, entry.length, entry.offset))
+ print()
ttf.close()
def ttDump(input, output, options):
if not options.quiet:
- print 'Dumping "%s" to "%s"...' % (input, output)
+ print('Dumping "%s" to "%s"...' % (input, output))
ttf = TTFont(input, 0, verbose=options.verbose, allowVID=options.allowVID,
lazy=False,
quiet=options.quiet,
@@ -209,7 +209,7 @@
def ttCompile(input, output, options):
if not options.quiet:
- print 'Compiling "%s" to "%s"...' % (input, output)
+ print('Compiling "%s" to "%s"...' % (input, output))
ttf = TTFont(options.mergeFile,
lazy=False,
recalcBBoxes=options.recalcBBoxes,
@@ -221,7 +221,7 @@
# XXX This shouldn't be here at all, it should be as close to the
# OTL code as possible.
overflowRecord = e.value
- print "Attempting to fix OTLOffsetOverflowError", e
+ print("Attempting to fix OTLOffsetOverflowError", e)
lastItem = overflowRecord
while True:
ok = 0
@@ -236,14 +236,14 @@
ttf.save(output)
break
except OTLOffsetOverflowError, e:
- print "Attempting to fix OTLOffsetOverflowError", e
+ print("Attempting to fix OTLOffsetOverflowError", e)
overflowRecord = e.value
if overflowRecord == lastItem:
raise
if options.verbose:
import time
- print "finished at", time.strftime("%H:%M:%S", time.localtime(time.time()))
+ print("finished at", time.strftime("%H:%M:%S", time.localtime(time.time())))
def guessFileType(fileName):
@@ -302,7 +302,7 @@
extension = ".otf"
action = ttCompile
else:
- print 'Unknown file type: "%s"' % input
+ print('Unknown file type: "%s"' % input)
continue
if options.outputFile:
@@ -322,7 +322,7 @@
"""Force the DOS Prompt window to stay open so the user gets
a chance to see what's wrong."""
import msvcrt
- print '(Hit any key to exit)'
+ print('(Hit any key to exit)')
while not msvcrt.kbhit():
pass
@@ -332,14 +332,14 @@
try:
process(jobs, options)
except KeyboardInterrupt:
- print "(Cancelled.)"
+ print("(Cancelled.)")
except SystemExit:
if sys.platform == "win32":
waitForKeyPress()
else:
raise
except TTLibError, e:
- print "Error:",e
+ print("Error:",e)
except:
if sys.platform == "win32":
import traceback
diff --git a/MetaTools/buildChangeLog.py b/MetaTools/buildChangeLog.py
index ec68e83..d29e379 100755
--- a/MetaTools/buildChangeLog.py
+++ b/MetaTools/buildChangeLog.py
@@ -7,4 +7,4 @@
os.chdir(fontToolsDir)
os.system("git2cl > Doc/ChangeLog")
-print "done."
+print("done.")
diff --git a/MetaTools/roundTrip.py b/MetaTools/roundTrip.py
index 4b13006..122b39b 100755
--- a/MetaTools/roundTrip.py
+++ b/MetaTools/roundTrip.py
@@ -25,7 +25,7 @@
def usage():
- print __doc__
+ print(__doc__)
sys.exit(2)
@@ -58,7 +58,7 @@
report.write("-------------------------------------------------------------\n")
report.writelines(lines)
else:
- print "(TTX files are the same)"
+ print("(TTX files are the same)")
finally:
for tmpFile in (xmlFile1, ttFile2, xmlFile2):
if os.path.exists(tmpFile):
@@ -80,10 +80,10 @@
try:
roundTrip(ttFile, options, report)
except KeyboardInterrupt:
- print "(Cancelled)"
+ print("(Cancelled)")
break
except:
- print "*** round tripping aborted ***"
+ print("*** round tripping aborted ***")
traceback.print_exc()
report.write("=============================================================\n")
report.write(" An exception occurred while round tripping")