2to3 --fix=print with manual fixup
This commit is contained in:
parent
d7e8d81a7a
commit
3ec6a25823
@ -369,16 +369,16 @@ if __name__ == "__main__":
|
|||||||
afm = AFM(path)
|
afm = AFM(path)
|
||||||
char = 'A'
|
char = 'A'
|
||||||
if afm.has_char(char):
|
if afm.has_char(char):
|
||||||
print afm[char] # print charnum, width and boundingbox
|
print(afm[char]) # print charnum, width and boundingbox
|
||||||
pair = ('A', 'V')
|
pair = ('A', 'V')
|
||||||
if afm.has_kernpair(pair):
|
if afm.has_kernpair(pair):
|
||||||
print afm[pair] # print kerning value for pair
|
print(afm[pair]) # print kerning value for pair
|
||||||
print afm.Version # various other afm entries have become attributes
|
print(afm.Version) # various other afm entries have become attributes
|
||||||
print afm.Weight
|
print(afm.Weight)
|
||||||
# afm.comments() returns a list of all Comment lines found in the AFM
|
# afm.comments() returns a list of all Comment lines found in the AFM
|
||||||
print afm.comments()
|
print(afm.comments())
|
||||||
#print afm.chars()
|
#print afm.chars()
|
||||||
#print afm.kernpairs()
|
#print afm.kernpairs()
|
||||||
print afm
|
print(afm)
|
||||||
afm.write(path + ".muck")
|
afm.write(path + ".muck")
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ class CFFWriter:
|
|||||||
count = 1
|
count = 1
|
||||||
while True:
|
while True:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "CFFWriter.toFile() iteration:", count
|
print("CFFWriter.toFile() iteration:", count)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
pos = 0
|
pos = 0
|
||||||
posList = [pos]
|
posList = [pos]
|
||||||
@ -155,7 +155,7 @@ class CFFWriter:
|
|||||||
break
|
break
|
||||||
lastPosList = posList
|
lastPosList = posList
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "CFFWriter.toFile() writing to file."
|
print("CFFWriter.toFile() writing to file.")
|
||||||
begin = file.tell()
|
begin = file.tell()
|
||||||
posList = [0]
|
posList = [0]
|
||||||
for item in self.data:
|
for item in self.data:
|
||||||
@ -314,7 +314,7 @@ class Index:
|
|||||||
self.items = []
|
self.items = []
|
||||||
return
|
return
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "loading %s at %s" % (name, file.tell())
|
print("loading %s at %s" % (name, file.tell()))
|
||||||
self.file = file
|
self.file = file
|
||||||
count = readCard16(file)
|
count = readCard16(file)
|
||||||
self.count = count
|
self.count = count
|
||||||
@ -324,7 +324,7 @@ class Index:
|
|||||||
return
|
return
|
||||||
offSize = readCard8(file)
|
offSize = readCard8(file)
|
||||||
if DEBUG:
|
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
|
assert offSize <= 4, "offSize too large: %s" % offSize
|
||||||
self.offsets = offsets = []
|
self.offsets = offsets = []
|
||||||
pad = '\0' * (4 - offSize)
|
pad = '\0' * (4 - offSize)
|
||||||
@ -336,7 +336,7 @@ class Index:
|
|||||||
self.offsetBase = file.tell() - 1
|
self.offsetBase = file.tell() - 1
|
||||||
file.seek(self.offsetBase + offsets[-1]) # pretend we've read the whole lot
|
file.seek(self.offsetBase + offsets[-1]) # pretend we've read the whole lot
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print " end of %s at %s" % (name, file.tell())
|
print(" end of %s at %s" % (name, file.tell()))
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.items)
|
return len(self.items)
|
||||||
@ -778,7 +778,7 @@ class CharsetConverter:
|
|||||||
file = parent.file
|
file = parent.file
|
||||||
file.seek(value)
|
file.seek(value)
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "loading charset at %s" % value
|
print("loading charset at %s" % value)
|
||||||
format = readCard8(file)
|
format = readCard8(file)
|
||||||
if format == 0:
|
if format == 0:
|
||||||
charset = parseCharset0(numGlyphs, file, parent.strings, isCID)
|
charset = parseCharset0(numGlyphs, file, parent.strings, isCID)
|
||||||
@ -788,7 +788,7 @@ class CharsetConverter:
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
assert len(charset) == numGlyphs
|
assert len(charset) == numGlyphs
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print " charset end at %s" % file.tell()
|
print(" charset end at %s" % file.tell())
|
||||||
else: # offset == 0 -> no charset data.
|
else: # offset == 0 -> no charset data.
|
||||||
if isCID or "CharStrings" not in parent.rawDict:
|
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.
|
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 @@ class EncodingConverter(SimpleConverter):
|
|||||||
file = parent.file
|
file = parent.file
|
||||||
file.seek(value)
|
file.seek(value)
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "loading Encoding at %s" % value
|
print("loading Encoding at %s" % value)
|
||||||
format = readCard8(file)
|
format = readCard8(file)
|
||||||
haveSupplement = format & 0x80
|
haveSupplement = format & 0x80
|
||||||
if haveSupplement:
|
if haveSupplement:
|
||||||
@ -1329,8 +1329,8 @@ class DictCompiler:
|
|||||||
|
|
||||||
def compile(self, reason):
|
def compile(self, reason):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "-- compiling %s for %s" % (self.__class__.__name__, reason)
|
print("-- compiling %s for %s" % (self.__class__.__name__, reason))
|
||||||
print "in baseDict: ", self
|
print("in baseDict: ", self)
|
||||||
rawDict = self.rawDict
|
rawDict = self.rawDict
|
||||||
data = []
|
data = []
|
||||||
for name in self.dictObj.order:
|
for name in self.dictObj.order:
|
||||||
@ -1463,7 +1463,7 @@ class BaseDict:
|
|||||||
def __init__(self, strings=None, file=None, offset=None):
|
def __init__(self, strings=None, file=None, offset=None):
|
||||||
self.rawDict = {}
|
self.rawDict = {}
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "loading %s at %s" % (self.__class__.__name__, offset)
|
print("loading %s at %s" % (self.__class__.__name__, offset))
|
||||||
self.file = file
|
self.file = file
|
||||||
self.offset = offset
|
self.offset = offset
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
@ -1471,7 +1471,7 @@ class BaseDict:
|
|||||||
|
|
||||||
def decompile(self, data):
|
def decompile(self, data):
|
||||||
if DEBUG:
|
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 = self.decompilerClass(self.strings)
|
||||||
dec.decompile(data)
|
dec.decompile(data)
|
||||||
self.rawDict = dec.getDict()
|
self.rawDict = dec.getDict()
|
||||||
@ -1552,7 +1552,7 @@ class TopDict(BaseDict):
|
|||||||
try:
|
try:
|
||||||
charString.decompile()
|
charString.decompile()
|
||||||
except:
|
except:
|
||||||
print "Error in charstring ", i
|
print("Error in charstring ", i)
|
||||||
import sys
|
import sys
|
||||||
type, value = sys. exc_info()[0:2]
|
type, value = sys. exc_info()[0:2]
|
||||||
raise type(value)
|
raise type(value)
|
||||||
|
@ -143,9 +143,9 @@ class FontFamily:
|
|||||||
header = header + struct.pack(*(">hh",) + self.ffIntl)
|
header = header + struct.pack(*(">hh",) + self.ffIntl)
|
||||||
header = header + struct.pack(">h", self.ffVersion)
|
header = header + struct.pack(">h", self.ffVersion)
|
||||||
if DEBUG:
|
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:
|
if self._rawheader != header:
|
||||||
print len(self._rawheader), len(header)
|
print(len(self._rawheader), len(header))
|
||||||
self._rawheader = header
|
self._rawheader = header
|
||||||
|
|
||||||
def _getfontassociationtable(self):
|
def _getfontassociationtable(self):
|
||||||
@ -169,9 +169,9 @@ class FontFamily:
|
|||||||
data = data + struct.pack(">3h", size, stype, ID)
|
data = data + struct.pack(">3h", size, stype, ID)
|
||||||
|
|
||||||
if DEBUG:
|
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:
|
if self._rawfontassociationtable != data:
|
||||||
print len(self._rawfontassociationtable), len(data)
|
print(len(self._rawfontassociationtable), len(data))
|
||||||
self._rawfontassociationtable = data
|
self._rawfontassociationtable = data
|
||||||
|
|
||||||
def _getoffsettable(self):
|
def _getoffsettable(self):
|
||||||
@ -248,7 +248,7 @@ class FontFamily:
|
|||||||
for width in table:
|
for width in table:
|
||||||
data = data + struct.pack('>h', width)
|
data = data + struct.pack('>h', width)
|
||||||
if DEBUG:
|
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
|
self._rawglyphwidthtable = data
|
||||||
|
|
||||||
def _getkerningtables(self):
|
def _getkerningtables(self):
|
||||||
@ -292,9 +292,9 @@ class FontFamily:
|
|||||||
data = string.join(data, '')
|
data = string.join(data, '')
|
||||||
|
|
||||||
if DEBUG:
|
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:
|
if self._rawkerningtables != data:
|
||||||
print len(self._rawkerningtables), len(data)
|
print(len(self._rawkerningtables), len(data))
|
||||||
self._rawkerningtables = data
|
self._rawkerningtables = data
|
||||||
|
|
||||||
def _getstylemappingtable(self):
|
def _getstylemappingtable(self):
|
||||||
@ -345,7 +345,7 @@ class FontFamily:
|
|||||||
data = data + '\0'
|
data = data + '\0'
|
||||||
|
|
||||||
if DEBUG:
|
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
|
self._rawstylemappingtable = data
|
||||||
|
|
||||||
def _unpackstylestrings(self):
|
def _unpackstylestrings(self):
|
||||||
|
@ -400,7 +400,7 @@ def printSegments(segments):
|
|||||||
segments on a single line as a tuple.
|
segments on a single line as a tuple.
|
||||||
"""
|
"""
|
||||||
for segment in segments:
|
for segment in segments:
|
||||||
print _segmentrepr(segment)
|
print(_segmentrepr(segment))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import doctest
|
import doctest
|
||||||
|
@ -56,10 +56,10 @@ def deHexString(h):
|
|||||||
def _test():
|
def _test():
|
||||||
import fontTools.misc.eexecOp as eexecOp
|
import fontTools.misc.eexecOp as eexecOp
|
||||||
testStr = "\0\0asdadads asds\265"
|
testStr = "\0\0asdadads asds\265"
|
||||||
print decrypt, decrypt(testStr, 12321)
|
print(decrypt, decrypt(testStr, 12321))
|
||||||
print eexecOp.decrypt, eexecOp.decrypt(testStr, 12321)
|
print(eexecOp.decrypt, eexecOp.decrypt(testStr, 12321))
|
||||||
print encrypt, encrypt(testStr, 12321)
|
print(encrypt, encrypt(testStr, 12321))
|
||||||
print eexecOp.encrypt, eexecOp.encrypt(testStr, 12321)
|
print(eexecOp.encrypt, eexecOp.encrypt(testStr, 12321))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -91,4 +91,4 @@ class ParamBlock:
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
fond = Res.GetNamedResource("FOND", "Helvetica")
|
fond = Res.GetNamedResource("FOND", "Helvetica")
|
||||||
print HomeResFile(fond)
|
print(HomeResFile(fond))
|
||||||
|
@ -304,7 +304,7 @@ class T2CharString(ByteCodeBase):
|
|||||||
try:
|
try:
|
||||||
bytecode = "".join(bytecode)
|
bytecode = "".join(bytecode)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print bytecode
|
print(bytecode)
|
||||||
raise
|
raise
|
||||||
self.setBytecode(bytecode)
|
self.setBytecode(bytecode)
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ def _test():
|
|||||||
afixed: 16.16F
|
afixed: 16.16F
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print 'size:', calcsize(format)
|
print('size:', calcsize(format))
|
||||||
|
|
||||||
class foo:
|
class foo:
|
||||||
pass
|
pass
|
||||||
@ -194,11 +194,11 @@ def _test():
|
|||||||
i.afixed = 1.5
|
i.afixed = 1.5
|
||||||
|
|
||||||
data = pack(format, i)
|
data = pack(format, i)
|
||||||
print 'data:', repr(data)
|
print('data:', repr(data))
|
||||||
print unpack(format, data)
|
print(unpack(format, data))
|
||||||
i2 = foo()
|
i2 = foo()
|
||||||
unpack(format, data, i2)
|
unpack(format, data, i2)
|
||||||
print vars(i2)
|
print(vars(i2))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
_test()
|
_test()
|
||||||
|
@ -75,7 +75,7 @@ class XMLReader:
|
|||||||
ttLib.debugmsg(msg)
|
ttLib.debugmsg(msg)
|
||||||
else:
|
else:
|
||||||
if not self.quiet:
|
if not self.quiet:
|
||||||
print msg
|
print(msg)
|
||||||
if tag == "GlyphOrder":
|
if tag == "GlyphOrder":
|
||||||
tableClass = ttLib.GlyphOrder
|
tableClass = ttLib.GlyphOrder
|
||||||
elif "ERROR" in attrs:
|
elif "ERROR" in attrs:
|
||||||
@ -118,7 +118,7 @@ class XMLReader:
|
|||||||
class ProgressPrinter:
|
class ProgressPrinter:
|
||||||
|
|
||||||
def __init__(self, title, maxval=100):
|
def __init__(self, title, maxval=100):
|
||||||
print title
|
print(title)
|
||||||
|
|
||||||
def set(self, val, maxval=None):
|
def set(self, val, maxval=None):
|
||||||
pass
|
pass
|
||||||
@ -127,5 +127,5 @@ class ProgressPrinter:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def setLabel(self, text):
|
def setLabel(self, text):
|
||||||
print text
|
print(text)
|
||||||
|
|
||||||
|
@ -301,4 +301,4 @@ if __name__ == "__main__":
|
|||||||
font.unpackGlyphs()
|
font.unpackGlyphs()
|
||||||
font.packGlyphs()
|
font.packGlyphs()
|
||||||
data2 = font.compile()
|
data2 = font.compile()
|
||||||
print "xxxxx", data == data2, len(data) == len(data2)
|
print("xxxxx", data == data2, len(data) == len(data2))
|
||||||
|
@ -339,14 +339,14 @@ def decomposeQuadraticSegment(points):
|
|||||||
class _TestPen(BasePen):
|
class _TestPen(BasePen):
|
||||||
"""Test class that prints PostScript to stdout."""
|
"""Test class that prints PostScript to stdout."""
|
||||||
def _moveTo(self, pt):
|
def _moveTo(self, pt):
|
||||||
print "%s %s moveto" % (pt[0], pt[1])
|
print("%s %s moveto" % (pt[0], pt[1]))
|
||||||
def _lineTo(self, pt):
|
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):
|
def _curveToOne(self, bcp1, bcp2, pt):
|
||||||
print "%s %s %s %s %s %s curveto" % (bcp1[0], bcp1[1],
|
print("%s %s %s %s %s %s curveto" % (bcp1[0], bcp1[1],
|
||||||
bcp2[0], bcp2[1], pt[0], pt[1])
|
bcp2[0], bcp2[1], pt[0], pt[1]))
|
||||||
def _closePath(self):
|
def _closePath(self):
|
||||||
print "closepath"
|
print("closepath")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -86,8 +86,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
pen = ControlBoundsPen(None)
|
pen = ControlBoundsPen(None)
|
||||||
draw(pen)
|
draw(pen)
|
||||||
print pen.bounds
|
print(pen.bounds)
|
||||||
|
|
||||||
pen = BoundsPen(None)
|
pen = BoundsPen(None)
|
||||||
draw(pen)
|
draw(pen)
|
||||||
print pen.bounds
|
print(pen.bounds)
|
||||||
|
@ -33,10 +33,10 @@ class ReportLabPen(BasePen):
|
|||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
import sys
|
import sys
|
||||||
if len(sys.argv) < 3:
|
if len(sys.argv) < 3:
|
||||||
print "Usage: reportLabPen.py <OTF/TTF font> <glyphname> [<image file to create>]"
|
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(" If no image file name is created, by default <glyphname>.png is created.")
|
||||||
print " example: reportLabPen.py Arial.TTF R test.png"
|
print(" example: reportLabPen.py Arial.TTF R test.png")
|
||||||
print " (The file format will be PNG, regardless of the image file name supplied)"
|
print(" (The file format will be PNG, regardless of the image file name supplied)")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
from fontTools.ttLib import TTFont
|
from fontTools.ttLib import TTFont
|
||||||
|
@ -301,7 +301,7 @@ class TTFont:
|
|||||||
debugmsg(report)
|
debugmsg(report)
|
||||||
else:
|
else:
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print report
|
print(report)
|
||||||
if tag not in self:
|
if tag not in self:
|
||||||
return
|
return
|
||||||
xmlTag = tagToXML(tag)
|
xmlTag = tagToXML(tag)
|
||||||
@ -390,7 +390,7 @@ class TTFont:
|
|||||||
if not self.ignoreDecompileErrors:
|
if not self.ignoreDecompileErrors:
|
||||||
raise
|
raise
|
||||||
# fall back to DefaultTable, retaining the binary table data
|
# 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
|
from .tables.DefaultTable import DefaultTable
|
||||||
import StringIO
|
import StringIO
|
||||||
file = StringIO.StringIO()
|
file = StringIO.StringIO()
|
||||||
@ -896,7 +896,7 @@ def xmlToTag(tag):
|
|||||||
|
|
||||||
def debugmsg(msg):
|
def debugmsg(msg):
|
||||||
import time
|
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
|
# Table order as recommended in the OpenType specification 1.4
|
||||||
|
@ -90,7 +90,7 @@ class SFNTReader:
|
|||||||
assert checksum == entry.checksum, "bad checksum for '%s' table" % tag
|
assert checksum == entry.checksum, "bad checksum for '%s' table" % tag
|
||||||
elif checksum != entry.checkSum:
|
elif checksum != entry.checkSum:
|
||||||
# Be friendly, and just print a warning.
|
# Be friendly, and just print a warning.
|
||||||
print "bad checksum for '%s' table" % tag
|
print("bad checksum for '%s' table" % tag)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def __delitem__(self, tag):
|
def __delitem__(self, tag):
|
||||||
|
@ -47,7 +47,7 @@ class BitmapGlyphMetrics:
|
|||||||
if name in metricNames:
|
if name in metricNames:
|
||||||
vars(self)[name] = safeEval(attrs['value'])
|
vars(self)[name] = safeEval(attrs['value'])
|
||||||
else:
|
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):
|
class BigGlyphMetrics(BitmapGlyphMetrics):
|
||||||
|
@ -167,7 +167,7 @@ class table_E_B_D_T_(DefaultTable.DefaultTable):
|
|||||||
assert glyphName not in bitmapGlyphDict, "Duplicate glyphs with the same name '%s' in the same strike." % glyphName
|
assert glyphName not in bitmapGlyphDict, "Duplicate glyphs with the same name '%s' in the same strike." % glyphName
|
||||||
bitmapGlyphDict[glyphName] = curGlyph
|
bitmapGlyphDict[glyphName] = curGlyph
|
||||||
else:
|
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
|
# Grow the strike data array to the appropriate size. The XML
|
||||||
# format allows the strike index value to be out of order.
|
# format allows the strike index value to be out of order.
|
||||||
@ -197,7 +197,7 @@ class EbdtComponent:
|
|||||||
if name in componentNames:
|
if name in componentNames:
|
||||||
vars(self)[name] = safeEval(attrs['value'])
|
vars(self)[name] = safeEval(attrs['value'])
|
||||||
else:
|
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.
|
# Helper functions for dealing with binary.
|
||||||
|
|
||||||
@ -471,7 +471,7 @@ def _createBitmapPlusMetricsMixin(metricsClass):
|
|||||||
self.metrics = metricsClass()
|
self.metrics = metricsClass()
|
||||||
self.metrics.fromXML(name, attrs, content, ttFont)
|
self.metrics.fromXML(name, attrs, content, ttFont)
|
||||||
elif name == oppositeMetricsName:
|
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
|
return BitmapPlusMetricsMixin
|
||||||
|
|
||||||
@ -685,7 +685,7 @@ class ComponentBitmapGlyph(BitmapGlyph):
|
|||||||
curComponent.fromXML(name, attrs, content, ttFont)
|
curComponent.fromXML(name, attrs, content, ttFont)
|
||||||
self.componentArray.append(curComponent)
|
self.componentArray.append(curComponent)
|
||||||
else:
|
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):
|
class ebdt_bitmap_format_8(BitmapPlusSmallMetricsMixin, ComponentBitmapGlyph):
|
||||||
|
@ -294,7 +294,7 @@ class BitmapSizeTable:
|
|||||||
elif name in dataNames:
|
elif name in dataNames:
|
||||||
vars(self)[name] = safeEval(attrs['value'])
|
vars(self)[name] = safeEval(attrs['value'])
|
||||||
else:
|
else:
|
||||||
print "Warning: unknown name '%s' being ignored in BitmapSizeTable." % name
|
print("Warning: unknown name '%s' being ignored in BitmapSizeTable." % name)
|
||||||
|
|
||||||
|
|
||||||
class SbitLineMetrics:
|
class SbitLineMetrics:
|
||||||
@ -503,7 +503,7 @@ class FixedSizeIndexSubTableMixin:
|
|||||||
self.metrics = BigGlyphMetrics()
|
self.metrics = BigGlyphMetrics()
|
||||||
self.metrics.fromXML(name, attrs, content, ttFont)
|
self.metrics.fromXML(name, attrs, content, ttFont)
|
||||||
elif name == SmallGlyphMetrics.__name__:
|
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):
|
def padBitmapData(self, data):
|
||||||
# Make sure that the data isn't bigger than the fixed size.
|
# Make sure that the data isn't bigger than the fixed size.
|
||||||
|
@ -105,7 +105,7 @@ class table_S_V_G_(DefaultTable.DefaultTable):
|
|||||||
self.decompile_format_1(data, ttFont)
|
self.decompile_format_1(data, ttFont)
|
||||||
else:
|
else:
|
||||||
if self.version != 0:
|
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)
|
self.decompile_format_0(data, ttFont)
|
||||||
|
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ class table_S_V_G_(DefaultTable.DefaultTable):
|
|||||||
if self.colorPalettes.numColorParams == 0:
|
if self.colorPalettes.numColorParams == 0:
|
||||||
self.colorPalettes = None
|
self.colorPalettes = None
|
||||||
else:
|
else:
|
||||||
print "Unknown", name, content
|
print("Unknown", name, content)
|
||||||
|
|
||||||
class DocumentIndexEntry:
|
class DocumentIndexEntry:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -33,7 +33,7 @@ class table__c_m_a_p(DefaultTable.DefaultTable):
|
|||||||
format, length = struct.unpack(">HL", data[offset:offset+6])
|
format, length = struct.unpack(">HL", data[offset:offset+6])
|
||||||
|
|
||||||
if not length:
|
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
|
continue
|
||||||
if format not in cmap_classes:
|
if format not in cmap_classes:
|
||||||
table = cmap_format_unknown(format)
|
table = cmap_format_unknown(format)
|
||||||
|
@ -113,10 +113,10 @@ class table__m_a_x_p(DefaultTable.DefaultTable):
|
|||||||
|
|
||||||
def testrepr(self):
|
def testrepr(self):
|
||||||
items = sorted(self.__dict__.items())
|
items = sorted(self.__dict__.items())
|
||||||
print ". . . . . . . . ."
|
print(". . . . . . . . .")
|
||||||
for combo in items:
|
for combo in items:
|
||||||
print " %s: %s" % combo
|
print(" %s: %s" % combo)
|
||||||
print ". . . . . . . . ."
|
print(". . . . . . . . .")
|
||||||
|
|
||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
if self.tableVersion != 0x00005000:
|
if self.tableVersion != 0x00005000:
|
||||||
|
@ -25,8 +25,7 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
|
|||||||
expectedStringOffset = 6 + n * nameRecordSize
|
expectedStringOffset = 6 + n * nameRecordSize
|
||||||
if stringOffset != expectedStringOffset:
|
if stringOffset != expectedStringOffset:
|
||||||
# XXX we need a warn function
|
# XXX we need a warn function
|
||||||
print "Warning: 'name' table stringOffset incorrect.",
|
print("Warning: 'name' table stringOffset incorrect. Expected: %s; Actual: %s" % (expectedStringOffset, stringOffset))
|
||||||
print "Expected: %s; Actual: %s" % (expectedStringOffset, stringOffset)
|
|
||||||
stringData = data[stringOffset:]
|
stringData = data[stringOffset:]
|
||||||
data = data[6:]
|
data = data[6:]
|
||||||
self.names = []
|
self.names = []
|
||||||
|
@ -45,12 +45,12 @@ class BaseTTXConverter(DefaultTable):
|
|||||||
if cachingStats:
|
if cachingStats:
|
||||||
stats = sorted([(v, k) for k, v in cachingStats.items()])
|
stats = sorted([(v, k) for k, v in cachingStats.items()])
|
||||||
stats.reverse()
|
stats.reverse()
|
||||||
print "cachingsstats for ", self.tableTag
|
print("cachingsstats for ", self.tableTag)
|
||||||
for v, k in stats:
|
for v, k in stats:
|
||||||
if v < 2:
|
if v < 2:
|
||||||
break
|
break
|
||||||
print v, k
|
print(v, k)
|
||||||
print "---", len(stats)
|
print("---", len(stats))
|
||||||
|
|
||||||
def compile(self, font):
|
def compile(self, font):
|
||||||
""" Create a top-level OTFWriter for the GPOS/GSUB table.
|
""" Create a top-level OTFWriter for the GPOS/GSUB table.
|
||||||
|
@ -225,8 +225,8 @@ class Table(Struct):
|
|||||||
return None
|
return None
|
||||||
if offset <= 3:
|
if offset <= 3:
|
||||||
# XXX hack to work around buggy pala.ttf
|
# XXX hack to work around buggy pala.ttf
|
||||||
print "*** Warning: offset is not 0, yet suspiciously low (%s). table: %s" \
|
print("*** Warning: offset is not 0, yet suspiciously low (%s). table: %s" \
|
||||||
% (offset, self.tableClass.__name__)
|
% (offset, self.tableClass.__name__))
|
||||||
return None
|
return None
|
||||||
table = self.tableClass()
|
table = self.tableClass()
|
||||||
table.reader = reader.getSubReader(offset)
|
table.reader = reader.getSubReader(offset)
|
||||||
|
@ -406,5 +406,5 @@ if __name__ == "__main__":
|
|||||||
p.fromBytecode(bc)
|
p.fromBytecode(bc)
|
||||||
asm = p.getAssembly()
|
asm = p.getAssembly()
|
||||||
p.fromAssembly(asm)
|
p.fromAssembly(asm)
|
||||||
print bc == p.getBytecode()
|
print(bc == p.getBytecode())
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ from fontTools.misc.macCreatorType import getMacCreatorAndType
|
|||||||
from fontTools import version
|
from fontTools import version
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print __doc__ % version
|
print(__doc__ % version)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
@ -120,11 +120,11 @@ class Options:
|
|||||||
for option, value in rawOptions:
|
for option, value in rawOptions:
|
||||||
# general options
|
# general options
|
||||||
if option == "-h":
|
if option == "-h":
|
||||||
print __doc__ % version
|
print(__doc__ % version)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif option == "-d":
|
elif option == "-d":
|
||||||
if not os.path.isdir(value):
|
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)
|
sys.exit(2)
|
||||||
self.outputDir = value
|
self.outputDir = value
|
||||||
elif option == "-o":
|
elif option == "-o":
|
||||||
@ -147,7 +147,7 @@ class Options:
|
|||||||
elif option == "-z":
|
elif option == "-z":
|
||||||
validOptions = ('raw', 'row', 'bitwise', 'extfile')
|
validOptions = ('raw', 'row', 'bitwise', 'extfile')
|
||||||
if value not in validOptions:
|
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)
|
sys.exit(2)
|
||||||
self.bitmapGlyphDataFormat = value
|
self.bitmapGlyphDataFormat = value
|
||||||
elif option == "-y":
|
elif option == "-y":
|
||||||
@ -162,10 +162,10 @@ class Options:
|
|||||||
elif option == "-e":
|
elif option == "-e":
|
||||||
self.ignoreDecompileErrors = False
|
self.ignoreDecompileErrors = False
|
||||||
if self.onlyTables and self.skipTables:
|
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)
|
sys.exit(2)
|
||||||
if self.mergeFile and numFiles > 1:
|
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)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
@ -174,24 +174,24 @@ def ttList(input, output, options):
|
|||||||
ttf = TTFont(input, fontNumber=options.fontNumber, lazy=True)
|
ttf = TTFont(input, fontNumber=options.fontNumber, lazy=True)
|
||||||
reader = ttf.reader
|
reader = ttf.reader
|
||||||
tags = sorted(reader.keys())
|
tags = sorted(reader.keys())
|
||||||
print 'Listing table info for "%s":' % input
|
print('Listing table info for "%s":' % input)
|
||||||
format = " %4s %10s %7s %7s"
|
format = " %4s %10s %7s %7s"
|
||||||
print format % ("tag ", " checksum", " length", " offset")
|
print(format % ("tag ", " checksum", " length", " offset"))
|
||||||
print format % ("----", "----------", "-------", "-------")
|
print(format % ("----", "----------", "-------", "-------"))
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
entry = reader.tables[tag]
|
entry = reader.tables[tag]
|
||||||
checkSum = int(entry.checkSum)
|
checkSum = int(entry.checkSum)
|
||||||
if checkSum < 0:
|
if checkSum < 0:
|
||||||
checkSum = checkSum + 0x100000000
|
checkSum = checkSum + 0x100000000
|
||||||
checksum = "0x" + string.zfill(hex(checkSum)[2:-1], 8)
|
checksum = "0x" + string.zfill(hex(checkSum)[2:-1], 8)
|
||||||
print format % (tag, checksum, entry.length, entry.offset)
|
print(format % (tag, checksum, entry.length, entry.offset))
|
||||||
print
|
print()
|
||||||
ttf.close()
|
ttf.close()
|
||||||
|
|
||||||
|
|
||||||
def ttDump(input, output, options):
|
def ttDump(input, output, options):
|
||||||
if not options.quiet:
|
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,
|
ttf = TTFont(input, 0, verbose=options.verbose, allowVID=options.allowVID,
|
||||||
lazy=False,
|
lazy=False,
|
||||||
quiet=options.quiet,
|
quiet=options.quiet,
|
||||||
@ -209,7 +209,7 @@ def ttDump(input, output, options):
|
|||||||
|
|
||||||
def ttCompile(input, output, options):
|
def ttCompile(input, output, options):
|
||||||
if not options.quiet:
|
if not options.quiet:
|
||||||
print 'Compiling "%s" to "%s"...' % (input, output)
|
print('Compiling "%s" to "%s"...' % (input, output))
|
||||||
ttf = TTFont(options.mergeFile,
|
ttf = TTFont(options.mergeFile,
|
||||||
lazy=False,
|
lazy=False,
|
||||||
recalcBBoxes=options.recalcBBoxes,
|
recalcBBoxes=options.recalcBBoxes,
|
||||||
@ -221,7 +221,7 @@ def ttCompile(input, output, options):
|
|||||||
# XXX This shouldn't be here at all, it should be as close to the
|
# XXX This shouldn't be here at all, it should be as close to the
|
||||||
# OTL code as possible.
|
# OTL code as possible.
|
||||||
overflowRecord = e.value
|
overflowRecord = e.value
|
||||||
print "Attempting to fix OTLOffsetOverflowError", e
|
print("Attempting to fix OTLOffsetOverflowError", e)
|
||||||
lastItem = overflowRecord
|
lastItem = overflowRecord
|
||||||
while True:
|
while True:
|
||||||
ok = 0
|
ok = 0
|
||||||
@ -236,14 +236,14 @@ def ttCompile(input, output, options):
|
|||||||
ttf.save(output)
|
ttf.save(output)
|
||||||
break
|
break
|
||||||
except OTLOffsetOverflowError, e:
|
except OTLOffsetOverflowError, e:
|
||||||
print "Attempting to fix OTLOffsetOverflowError", e
|
print("Attempting to fix OTLOffsetOverflowError", e)
|
||||||
overflowRecord = e.value
|
overflowRecord = e.value
|
||||||
if overflowRecord == lastItem:
|
if overflowRecord == lastItem:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
import time
|
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):
|
def guessFileType(fileName):
|
||||||
@ -302,7 +302,7 @@ def parseOptions(args):
|
|||||||
extension = ".otf"
|
extension = ".otf"
|
||||||
action = ttCompile
|
action = ttCompile
|
||||||
else:
|
else:
|
||||||
print 'Unknown file type: "%s"' % input
|
print('Unknown file type: "%s"' % input)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if options.outputFile:
|
if options.outputFile:
|
||||||
@ -322,7 +322,7 @@ def waitForKeyPress():
|
|||||||
"""Force the DOS Prompt window to stay open so the user gets
|
"""Force the DOS Prompt window to stay open so the user gets
|
||||||
a chance to see what's wrong."""
|
a chance to see what's wrong."""
|
||||||
import msvcrt
|
import msvcrt
|
||||||
print '(Hit any key to exit)'
|
print('(Hit any key to exit)')
|
||||||
while not msvcrt.kbhit():
|
while not msvcrt.kbhit():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -332,14 +332,14 @@ def main(args):
|
|||||||
try:
|
try:
|
||||||
process(jobs, options)
|
process(jobs, options)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print "(Cancelled.)"
|
print("(Cancelled.)")
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
waitForKeyPress()
|
waitForKeyPress()
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
except TTLibError, e:
|
except TTLibError, e:
|
||||||
print "Error:",e
|
print("Error:",e)
|
||||||
except:
|
except:
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -7,4 +7,4 @@ fontToolsDir = os.path.dirname(os.path.dirname(os.path.normpath(
|
|||||||
|
|
||||||
os.chdir(fontToolsDir)
|
os.chdir(fontToolsDir)
|
||||||
os.system("git2cl > Doc/ChangeLog")
|
os.system("git2cl > Doc/ChangeLog")
|
||||||
print "done."
|
print("done.")
|
||||||
|
@ -25,7 +25,7 @@ class Error(Exception): pass
|
|||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print __doc__
|
print(__doc__)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ def roundTrip(ttFile1, options, report):
|
|||||||
report.write("-------------------------------------------------------------\n")
|
report.write("-------------------------------------------------------------\n")
|
||||||
report.writelines(lines)
|
report.writelines(lines)
|
||||||
else:
|
else:
|
||||||
print "(TTX files are the same)"
|
print("(TTX files are the same)")
|
||||||
finally:
|
finally:
|
||||||
for tmpFile in (xmlFile1, ttFile2, xmlFile2):
|
for tmpFile in (xmlFile1, ttFile2, xmlFile2):
|
||||||
if os.path.exists(tmpFile):
|
if os.path.exists(tmpFile):
|
||||||
@ -80,10 +80,10 @@ def main(args):
|
|||||||
try:
|
try:
|
||||||
roundTrip(ttFile, options, report)
|
roundTrip(ttFile, options, report)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print "(Cancelled)"
|
print("(Cancelled)")
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
print "*** round tripping aborted ***"
|
print("*** round tripping aborted ***")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
report.write("=============================================================\n")
|
report.write("=============================================================\n")
|
||||||
report.write(" An exception occurred while round tripping")
|
report.write(" An exception occurred while round tripping")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user