2to3 --fix=idioms
This commit is contained in:
parent
c2e2e835ec
commit
ac1b435946
@ -177,7 +177,7 @@ class AFM:
|
|||||||
ncomponents = int(m.group(2))
|
ncomponents = int(m.group(2))
|
||||||
rest = rest[m.regs[0][1]:]
|
rest = rest[m.regs[0][1]:]
|
||||||
components = []
|
components = []
|
||||||
while 1:
|
while True:
|
||||||
m = componentRE.match(rest)
|
m = componentRE.match(rest)
|
||||||
if m is None:
|
if m is None:
|
||||||
raise error("syntax error in AFM file: " + repr(rest))
|
raise error("syntax error in AFM file: " + repr(rest))
|
||||||
@ -215,8 +215,7 @@ class AFM:
|
|||||||
lines.append(attr + " " + str(value))
|
lines.append(attr + " " + str(value))
|
||||||
# then write the attributes we don't know about,
|
# then write the attributes we don't know about,
|
||||||
# in alphabetical order
|
# in alphabetical order
|
||||||
items = attrs.items()
|
items = sorted(attrs.items())
|
||||||
items.sort()
|
|
||||||
for attr, value in items:
|
for attr, value in items:
|
||||||
if attr in preferredAttributeOrder:
|
if attr in preferredAttributeOrder:
|
||||||
continue
|
continue
|
||||||
@ -254,8 +253,7 @@ class AFM:
|
|||||||
lines.append("EndKernData")
|
lines.append("EndKernData")
|
||||||
|
|
||||||
if self._composites:
|
if self._composites:
|
||||||
composites = self._composites.items()
|
composites = sorted(self._composites.items())
|
||||||
composites.sort()
|
|
||||||
lines.append("StartComposites %s" % len(self._composites))
|
lines.append("StartComposites %s" % len(self._composites))
|
||||||
for charname, components in composites:
|
for charname, components in composites:
|
||||||
line = "CC %s %s ;" % (charname, len(components))
|
line = "CC %s %s ;" % (charname, len(components))
|
||||||
@ -316,7 +314,7 @@ class AFM:
|
|||||||
raise AttributeError(attr)
|
raise AttributeError(attr)
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if type(key) == types.TupleType:
|
if isinstance(key, types.TupleType):
|
||||||
# key is a tuple, return the kernpair
|
# key is a tuple, return the kernpair
|
||||||
return self._kerning[key]
|
return self._kerning[key]
|
||||||
else:
|
else:
|
||||||
@ -324,7 +322,7 @@ class AFM:
|
|||||||
return self._chars[key]
|
return self._chars[key]
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
if type(key) == types.TupleType:
|
if isinstance(key, types.TupleType):
|
||||||
# key is a tuple, set kernpair
|
# key is a tuple, set kernpair
|
||||||
self._kerning[key] = value
|
self._kerning[key] = value
|
||||||
else:
|
else:
|
||||||
@ -332,7 +330,7 @@ class AFM:
|
|||||||
self._chars[key] = value
|
self._chars[key] = value
|
||||||
|
|
||||||
def __delitem__(self, key):
|
def __delitem__(self, key):
|
||||||
if type(key) == types.TupleType:
|
if isinstance(key, types.TupleType):
|
||||||
# key is a tuple, del kernpair
|
# key is a tuple, del kernpair
|
||||||
del self._kerning[key]
|
del self._kerning[key]
|
||||||
else:
|
else:
|
||||||
|
@ -136,7 +136,7 @@ class CFFWriter:
|
|||||||
def toFile(self, file):
|
def toFile(self, file):
|
||||||
lastPosList = None
|
lastPosList = None
|
||||||
count = 1
|
count = 1
|
||||||
while 1:
|
while True:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "CFFWriter.toFile() iteration:", count
|
print "CFFWriter.toFile() iteration:", count
|
||||||
count = count + 1
|
count = count + 1
|
||||||
@ -558,8 +558,7 @@ class CharStrings:
|
|||||||
return self.charStrings[name], sel
|
return self.charStrings[name], sel
|
||||||
|
|
||||||
def toXML(self, xmlWriter, progress):
|
def toXML(self, xmlWriter, progress):
|
||||||
names = self.keys()
|
names = sorted(self.keys())
|
||||||
names.sort()
|
|
||||||
i = 0
|
i = 0
|
||||||
step = 10
|
step = 10
|
||||||
numGlyphs = len(names)
|
numGlyphs = len(names)
|
||||||
|
@ -206,8 +206,7 @@ class FontFamily:
|
|||||||
|
|
||||||
def _buildboundingboxtable(self):
|
def _buildboundingboxtable(self):
|
||||||
if self.boundingBoxes and self._rawoffsettable[:6] == '\0\0\0\0\0\6':
|
if self.boundingBoxes and self._rawoffsettable[:6] == '\0\0\0\0\0\6':
|
||||||
boxes = self.boundingBoxes.items()
|
boxes = sorted(self.boundingBoxes.items())
|
||||||
boxes.sort()
|
|
||||||
data = '\0\0\0\0\0\6' + struct.pack(">h", len(boxes) - 1)
|
data = '\0\0\0\0\0\6' + struct.pack(">h", len(boxes) - 1)
|
||||||
for style, (l, b, r, t) in boxes:
|
for style, (l, b, r, t) in boxes:
|
||||||
data = data + struct.pack(">hhhhh", style, l, b, r, t)
|
data = data + struct.pack(">hhhhh", style, l, b, r, t)
|
||||||
@ -241,8 +240,7 @@ class FontFamily:
|
|||||||
return
|
return
|
||||||
numberofentries = len(self.widthTables)
|
numberofentries = len(self.widthTables)
|
||||||
data = struct.pack('>h', numberofentries - 1)
|
data = struct.pack('>h', numberofentries - 1)
|
||||||
tables = self.widthTables.items()
|
tables = sorted(self.widthTables.items())
|
||||||
tables.sort()
|
|
||||||
for stylecode, table in tables:
|
for stylecode, table in tables:
|
||||||
data = data + struct.pack('>h', stylecode)
|
data = data + struct.pack('>h', stylecode)
|
||||||
if len(table) != (3 + self.ffLastChar - self.ffFirstChar):
|
if len(table) != (3 + self.ffLastChar - self.ffFirstChar):
|
||||||
@ -284,8 +282,7 @@ class FontFamily:
|
|||||||
return
|
return
|
||||||
numberofentries = len(self.kernTables)
|
numberofentries = len(self.kernTables)
|
||||||
data = [struct.pack('>h', numberofentries - 1)]
|
data = [struct.pack('>h', numberofentries - 1)]
|
||||||
tables = self.kernTables.items()
|
tables = sorted(self.kernTables.items())
|
||||||
tables.sort()
|
|
||||||
for stylecode, table in tables:
|
for stylecode, table in tables:
|
||||||
data.append(struct.pack('>h', stylecode))
|
data.append(struct.pack('>h', stylecode))
|
||||||
data.append(struct.pack('>h', len(table))) # numberofpairs
|
data.append(struct.pack('>h', len(table))) # numberofpairs
|
||||||
@ -375,8 +372,7 @@ class FontFamily:
|
|||||||
for part in split:
|
for part in split:
|
||||||
nameparts[part] = None
|
nameparts[part] = None
|
||||||
del nameparts[self.ffFamilyName]
|
del nameparts[self.ffFamilyName]
|
||||||
nameparts = nameparts.keys()
|
nameparts = sorted(nameparts.keys())
|
||||||
nameparts.sort()
|
|
||||||
items = splitnames.items()
|
items = splitnames.items()
|
||||||
items.sort()
|
items.sort()
|
||||||
numindices = 0
|
numindices = 0
|
||||||
@ -433,8 +429,7 @@ class FontFamily:
|
|||||||
return
|
return
|
||||||
numberofentries = len(self.glyphEncoding)
|
numberofentries = len(self.glyphEncoding)
|
||||||
data = struct.pack(">h", numberofentries)
|
data = struct.pack(">h", numberofentries)
|
||||||
items = self.glyphEncoding.items()
|
items = sorted(self.glyphEncoding.items())
|
||||||
items.sort()
|
|
||||||
for glyphcode, glyphname in items:
|
for glyphcode, glyphname in items:
|
||||||
data = data + chr(glyphcode) + chr(len(glyphname)) + glyphname
|
data = data + chr(glyphcode) + chr(len(glyphname)) + glyphname
|
||||||
self._rawglyphencodingsubtable = data
|
self._rawglyphencodingsubtable = data
|
||||||
@ -497,8 +492,7 @@ class BitmapFontFile:
|
|||||||
for fond in self.fonds:
|
for fond in self.fonds:
|
||||||
fond.parse()
|
fond.parse()
|
||||||
if hasattr(fond, "psNames") and fond.psNames:
|
if hasattr(fond, "psNames") and fond.psNames:
|
||||||
psNames = fond.psNames.values()
|
psNames = sorted(fond.psNames.values())
|
||||||
psNames.sort()
|
|
||||||
self.fondsbyname[psNames[0]] = fond
|
self.fondsbyname[psNames[0]] = fond
|
||||||
|
|
||||||
def minimalparse(self):
|
def minimalparse(self):
|
||||||
|
@ -132,8 +132,7 @@ def splitQuadratic(pt1, pt2, pt3, where, isHorizontal):
|
|||||||
a, b, c = calcQuadraticParameters(pt1, pt2, pt3)
|
a, b, c = calcQuadraticParameters(pt1, pt2, pt3)
|
||||||
solutions = solveQuadratic(a[isHorizontal], b[isHorizontal],
|
solutions = solveQuadratic(a[isHorizontal], b[isHorizontal],
|
||||||
c[isHorizontal] - where)
|
c[isHorizontal] - where)
|
||||||
solutions = [t for t in solutions if 0 <= t < 1]
|
solutions = sorted([t for t in solutions if 0 <= t < 1])
|
||||||
solutions.sort()
|
|
||||||
if not solutions:
|
if not solutions:
|
||||||
return [(pt1, pt2, pt3)]
|
return [(pt1, pt2, pt3)]
|
||||||
return _splitQuadraticAtT(a, b, c, *solutions)
|
return _splitQuadraticAtT(a, b, c, *solutions)
|
||||||
@ -157,8 +156,7 @@ def splitCubic(pt1, pt2, pt3, pt4, where, isHorizontal):
|
|||||||
a, b, c, d = calcCubicParameters(pt1, pt2, pt3, pt4)
|
a, b, c, d = calcCubicParameters(pt1, pt2, pt3, pt4)
|
||||||
solutions = solveCubic(a[isHorizontal], b[isHorizontal], c[isHorizontal],
|
solutions = solveCubic(a[isHorizontal], b[isHorizontal], c[isHorizontal],
|
||||||
d[isHorizontal] - where)
|
d[isHorizontal] - where)
|
||||||
solutions = [t for t in solutions if 0 <= t < 1]
|
solutions = sorted([t for t in solutions if 0 <= t < 1])
|
||||||
solutions.sort()
|
|
||||||
if not solutions:
|
if not solutions:
|
||||||
return [(pt1, pt2, pt3, pt4)]
|
return [(pt1, pt2, pt3, pt4)]
|
||||||
return _splitCubicAtT(a, b, c, d, *solutions)
|
return _splitCubicAtT(a, b, c, d, *solutions)
|
||||||
|
@ -65,7 +65,7 @@ class ByteCodeBase:
|
|||||||
|
|
||||||
def read_realNumber(self, b0, data, index):
|
def read_realNumber(self, b0, data, index):
|
||||||
number = ''
|
number = ''
|
||||||
while 1:
|
while True:
|
||||||
b = ord(data[index])
|
b = ord(data[index])
|
||||||
index = index + 1
|
index = index + 1
|
||||||
nibble0 = (b & 0xf0) >> 4
|
nibble0 = (b & 0xf0) >> 4
|
||||||
@ -87,7 +87,7 @@ def buildOperatorDict(operatorList):
|
|||||||
oper[item[0]] = item[1]
|
oper[item[0]] = item[1]
|
||||||
else:
|
else:
|
||||||
oper[item[0]] = item[1:]
|
oper[item[0]] = item[1:]
|
||||||
if type(item[0]) == types.TupleType:
|
if isinstance(item[0], types.TupleType):
|
||||||
opc[item[1]] = item[0]
|
opc[item[1]] = item[0]
|
||||||
else:
|
else:
|
||||||
opc[item[1]] = (item[0],)
|
opc[item[1]] = (item[0],)
|
||||||
@ -334,7 +334,7 @@ class T2CharString(ByteCodeBase):
|
|||||||
return None, 0, 0
|
return None, 0, 0
|
||||||
token = self.program[index]
|
token = self.program[index]
|
||||||
index = index + 1
|
index = index + 1
|
||||||
isOperator = type(token) == StringType
|
isOperator = isinstance(token, StringType)
|
||||||
return token, isOperator, index
|
return token, isOperator, index
|
||||||
|
|
||||||
def getBytes(self, index, nBytes):
|
def getBytes(self, index, nBytes):
|
||||||
@ -364,7 +364,7 @@ class T2CharString(ByteCodeBase):
|
|||||||
else:
|
else:
|
||||||
index = 0
|
index = 0
|
||||||
args = []
|
args = []
|
||||||
while 1:
|
while True:
|
||||||
token, isOperator, index = self.getToken(index)
|
token, isOperator, index = self.getToken(index)
|
||||||
if token is None:
|
if token is None:
|
||||||
break
|
break
|
||||||
@ -472,7 +472,7 @@ class T1CharString(T2CharString):
|
|||||||
return
|
return
|
||||||
program = []
|
program = []
|
||||||
index = 0
|
index = 0
|
||||||
while 1:
|
while True:
|
||||||
token, isOperator, index = self.getToken(index)
|
token, isOperator, index = self.getToken(index)
|
||||||
if token is None:
|
if token is None:
|
||||||
break
|
break
|
||||||
@ -510,7 +510,7 @@ class SimpleT2Decompiler:
|
|||||||
pushToProgram = lambda x: None
|
pushToProgram = lambda x: None
|
||||||
pushToStack = self.operandStack.append
|
pushToStack = self.operandStack.append
|
||||||
index = 0
|
index = 0
|
||||||
while 1:
|
while True:
|
||||||
token, isOperator, index = charString.getToken(index)
|
token, isOperator, index = charString.getToken(index)
|
||||||
if token is None:
|
if token is None:
|
||||||
break # we're done!
|
break # we're done!
|
||||||
@ -1143,7 +1143,7 @@ class DictDecompiler(ByteCodeBase):
|
|||||||
return None, index
|
return None, index
|
||||||
|
|
||||||
def handle_operator(self, operator, argType):
|
def handle_operator(self, operator, argType):
|
||||||
if type(argType) == type(()):
|
if isinstance(argType, type(())):
|
||||||
value = ()
|
value = ()
|
||||||
for i in range(len(argType)-1, -1, -1):
|
for i in range(len(argType)-1, -1, -1):
|
||||||
arg = argType[i]
|
arg = argType[i]
|
||||||
|
@ -63,7 +63,7 @@ error = "sstruct.error"
|
|||||||
def pack(format, object):
|
def pack(format, object):
|
||||||
formatstring, names, fixes = getformat(format)
|
formatstring, names, fixes = getformat(format)
|
||||||
elements = []
|
elements = []
|
||||||
if type(object) is not types.DictType:
|
if not isinstance(object, types.DictType):
|
||||||
object = object.__dict__
|
object = object.__dict__
|
||||||
for name in names:
|
for name in names:
|
||||||
value = object[name]
|
value = object[name]
|
||||||
@ -78,7 +78,7 @@ def unpack(format, data, object=None):
|
|||||||
if object is None:
|
if object is None:
|
||||||
object = {}
|
object = {}
|
||||||
formatstring, names, fixes = getformat(format)
|
formatstring, names, fixes = getformat(format)
|
||||||
if type(object) is types.DictType:
|
if isinstance(object, types.DictType):
|
||||||
dict = object
|
dict = object
|
||||||
else:
|
else:
|
||||||
dict = object.__dict__
|
dict = object.__dict__
|
||||||
|
@ -77,8 +77,7 @@ def caselessSort(alist):
|
|||||||
(lower(item), item), alist)
|
(lower(item), item), alist)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# at least one element in alist is not a string, proceed the normal way...
|
# at least one element in alist is not a string, proceed the normal way...
|
||||||
alist = alist[:]
|
alist = sorted(alist[:])
|
||||||
alist.sort()
|
|
||||||
return alist
|
return alist
|
||||||
else:
|
else:
|
||||||
tupledlist.sort()
|
tupledlist.sort()
|
||||||
|
@ -37,7 +37,7 @@ class XMLReader:
|
|||||||
parser.CharacterDataHandler = self._characterDataHandler
|
parser.CharacterDataHandler = self._characterDataHandler
|
||||||
|
|
||||||
pos = 0
|
pos = 0
|
||||||
while 1:
|
while True:
|
||||||
chunk = file.read(BUFSIZE)
|
chunk = file.read(BUFSIZE)
|
||||||
if not chunk:
|
if not chunk:
|
||||||
parser.Parse(chunk, 1)
|
parser.Parse(chunk, 1)
|
||||||
|
@ -108,8 +108,7 @@ class XMLWriter:
|
|||||||
def stringifyattrs(self, *args, **kwargs):
|
def stringifyattrs(self, *args, **kwargs):
|
||||||
if kwargs:
|
if kwargs:
|
||||||
assert not args
|
assert not args
|
||||||
attributes = kwargs.items()
|
attributes = sorted(kwargs.items())
|
||||||
attributes.sort()
|
|
||||||
elif args:
|
elif args:
|
||||||
assert len(args) == 1
|
assert len(args) == 1
|
||||||
attributes = args[0]
|
attributes = args[0]
|
||||||
|
@ -276,7 +276,7 @@ def dataFromFile(pathOrFSSpec, nameOrID="", resType='NFNT'):
|
|||||||
if not nameOrID:
|
if not nameOrID:
|
||||||
# just take the first in the file
|
# just take the first in the file
|
||||||
res = Res.Get1IndResource(resType, 1)
|
res = Res.Get1IndResource(resType, 1)
|
||||||
elif type(nameOrID) == types.IntType:
|
elif isinstance(nameOrID, types.IntType):
|
||||||
res = Res.Get1Resource(resType, nameOrID)
|
res = Res.Get1Resource(resType, nameOrID)
|
||||||
else:
|
else:
|
||||||
res = Res.Get1NamedResource(resType, nameOrID)
|
res = Res.Get1NamedResource(resType, nameOrID)
|
||||||
|
@ -120,8 +120,7 @@ class PointInsidePen(BasePen):
|
|||||||
cy = (y2 - dy) * 3.0
|
cy = (y2 - dy) * 3.0
|
||||||
by = (y3 - y2) * 3.0 - cy
|
by = (y3 - y2) * 3.0 - cy
|
||||||
ay = y4 - dy - cy - by
|
ay = y4 - dy - cy - by
|
||||||
solutions = solveCubic(ay, by, cy, dy - y)
|
solutions = sorted(solveCubic(ay, by, cy, dy - y))
|
||||||
solutions.sort()
|
|
||||||
solutions = [t for t in solutions if ZERO_MINUS_EPSILON <= t <= ONE_PLUS_EPSILON]
|
solutions = [t for t in solutions if ZERO_MINUS_EPSILON <= t <= ONE_PLUS_EPSILON]
|
||||||
if not solutions:
|
if not solutions:
|
||||||
return
|
return
|
||||||
@ -176,8 +175,7 @@ class PointInsidePen(BasePen):
|
|||||||
c = y1
|
c = y1
|
||||||
b = (y2 - c) * 2.0
|
b = (y2 - c) * 2.0
|
||||||
a = y3 - c - b
|
a = y3 - c - b
|
||||||
solutions = solveQuadratic(a, b, c - y)
|
solutions = sorted(solveQuadratic(a, b, c - y))
|
||||||
solutions.sort()
|
|
||||||
solutions = [t for t in solutions if ZERO_MINUS_EPSILON <= t <= ONE_PLUS_EPSILON]
|
solutions = [t for t in solutions if ZERO_MINUS_EPSILON <= t <= ONE_PLUS_EPSILON]
|
||||||
if not solutions:
|
if not solutions:
|
||||||
return
|
return
|
||||||
|
@ -177,7 +177,7 @@ def readPFB(path, onlyHeader=0):
|
|||||||
"""reads a PFB font file, returns raw data"""
|
"""reads a PFB font file, returns raw data"""
|
||||||
f = open(path, "rb")
|
f = open(path, "rb")
|
||||||
data = []
|
data = []
|
||||||
while 1:
|
while True:
|
||||||
if f.read(1) != chr(128):
|
if f.read(1) != chr(128):
|
||||||
raise T1Error('corrupt PFB file')
|
raise T1Error('corrupt PFB file')
|
||||||
code = ord(f.read(1))
|
code = ord(f.read(1))
|
||||||
@ -311,7 +311,7 @@ def decryptType1(data):
|
|||||||
|
|
||||||
def findEncryptedChunks(data):
|
def findEncryptedChunks(data):
|
||||||
chunks = []
|
chunks = []
|
||||||
while 1:
|
while True:
|
||||||
eBegin = string.find(data, EEXECBEGIN)
|
eBegin = string.find(data, EEXECBEGIN)
|
||||||
if eBegin < 0:
|
if eBegin < 0:
|
||||||
break
|
break
|
||||||
|
@ -519,8 +519,7 @@ class TTFont:
|
|||||||
|
|
||||||
def getGlyphNames(self):
|
def getGlyphNames(self):
|
||||||
"""Get a list of glyph names, sorted alphabetically."""
|
"""Get a list of glyph names, sorted alphabetically."""
|
||||||
glyphNames = self.getGlyphOrder()[:]
|
glyphNames = sorted(self.getGlyphOrder()[:])
|
||||||
glyphNames.sort()
|
|
||||||
return glyphNames
|
return glyphNames
|
||||||
|
|
||||||
def getGlyphNames2(self):
|
def getGlyphNames2(self):
|
||||||
@ -913,8 +912,7 @@ def sortedTagList(tagList, tableOrder=None):
|
|||||||
specification, or according to a custom tableOrder. If given and not
|
specification, or according to a custom tableOrder. If given and not
|
||||||
None, tableOrder needs to be a list of tag names.
|
None, tableOrder needs to be a list of tag names.
|
||||||
"""
|
"""
|
||||||
tagList = list(tagList)
|
tagList = sorted(tagList)
|
||||||
tagList.sort()
|
|
||||||
if tableOrder is None:
|
if tableOrder is None:
|
||||||
if "DSIG" in tagList:
|
if "DSIG" in tagList:
|
||||||
# DSIG should be last (XXX spec reference?)
|
# DSIG should be last (XXX spec reference?)
|
||||||
|
@ -60,7 +60,7 @@ class SFNTResourceReader:
|
|||||||
def __init__(self, path, res_name_or_index):
|
def __init__(self, path, res_name_or_index):
|
||||||
resref = MyOpenResFile(path)
|
resref = MyOpenResFile(path)
|
||||||
Res.UseResFile(resref)
|
Res.UseResFile(resref)
|
||||||
if type(res_name_or_index) == type(""):
|
if isinstance(res_name_or_index, type("")):
|
||||||
res = Res.Get1NamedResource('sfnt', res_name_or_index)
|
res = Res.Get1NamedResource('sfnt', res_name_or_index)
|
||||||
else:
|
else:
|
||||||
res = Res.Get1IndResource('sfnt', res_name_or_index)
|
res = Res.Get1IndResource('sfnt', res_name_or_index)
|
||||||
|
@ -173,8 +173,7 @@ class SFNTWriter:
|
|||||||
"""All tables must have been written to disk. Now write the
|
"""All tables must have been written to disk. Now write the
|
||||||
directory.
|
directory.
|
||||||
"""
|
"""
|
||||||
tables = self.tables.items()
|
tables = sorted(self.tables.items())
|
||||||
tables.sort()
|
|
||||||
if len(tables) != self.numTables:
|
if len(tables) != self.numTables:
|
||||||
from fontTools import ttLib
|
from fontTools import ttLib
|
||||||
raise ttLib.TTLibError("wrong number of tables; expected %d, found %d" % (self.numTables, len(tables)))
|
raise ttLib.TTLibError("wrong number of tables; expected %d, found %d" % (self.numTables, len(tables)))
|
||||||
@ -250,8 +249,7 @@ class SFNTWriter:
|
|||||||
# Create a SFNT directory for checksum calculation purposes
|
# Create a SFNT directory for checksum calculation purposes
|
||||||
self.searchRange, self.entrySelector, self.rangeShift = getSearchRange(self.numTables)
|
self.searchRange, self.entrySelector, self.rangeShift = getSearchRange(self.numTables)
|
||||||
directory = sstruct.pack(sfntDirectoryFormat, self)
|
directory = sstruct.pack(sfntDirectoryFormat, self)
|
||||||
tables = self.tables.items()
|
tables = sorted(self.tables.items())
|
||||||
tables.sort()
|
|
||||||
for tag, entry in tables:
|
for tag, entry in tables:
|
||||||
sfntEntry = SFNTDirectoryEntry()
|
sfntEntry = SFNTDirectoryEntry()
|
||||||
for item in ['tag', 'checkSum', 'offset', 'length']:
|
for item in ['tag', 'checkSum', 'offset', 'length']:
|
||||||
|
@ -40,7 +40,7 @@ class BitmapGlyphMetrics:
|
|||||||
def fromXML(self, name, attrs, content, ttFont):
|
def fromXML(self, name, attrs, content, ttFont):
|
||||||
metricNames = set(sstruct.getformat(self.__class__.binaryFormat)[1])
|
metricNames = set(sstruct.getformat(self.__class__.binaryFormat)[1])
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
# Make sure this is a metric that is needed by GlyphMetrics.
|
# Make sure this is a metric that is needed by GlyphMetrics.
|
||||||
|
@ -119,7 +119,7 @@ class table_C_O_L_R_(DefaultTable.DefaultTable):
|
|||||||
|
|
||||||
|
|
||||||
def __getitem__(self, glyphSelector):
|
def __getitem__(self, glyphSelector):
|
||||||
if type(glyphSelector) == IntType:
|
if isinstance(glyphSelector, IntType):
|
||||||
# its a gid, convert to glyph name
|
# its a gid, convert to glyph name
|
||||||
glyphSelector = self.getGlyphName(glyphSelector)
|
glyphSelector = self.getGlyphName(glyphSelector)
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ class table_C_O_L_R_(DefaultTable.DefaultTable):
|
|||||||
return self.ColorLayers[glyphSelector]
|
return self.ColorLayers[glyphSelector]
|
||||||
|
|
||||||
def __setitem__(self, glyphSelector, value):
|
def __setitem__(self, glyphSelector, value):
|
||||||
if type(glyphSelector) == IntType:
|
if isinstance(glyphSelector, IntType):
|
||||||
# its a gid, convert to glyph name
|
# its a gid, convert to glyph name
|
||||||
glyphSelector = self.getGlyphName(glyphSelector)
|
glyphSelector = self.getGlyphName(glyphSelector)
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ class LayerRecord:
|
|||||||
def fromXML(self, eltname, attrs, content, ttFont):
|
def fromXML(self, eltname, attrs, content, ttFont):
|
||||||
for (name, value) in attrs.items():
|
for (name, value) in attrs.items():
|
||||||
if name == "name":
|
if name == "name":
|
||||||
if type(value) == IntType:
|
if isinstance(value, IntType):
|
||||||
value = ttFont.getGlyphName(value)
|
value = ttFont.getGlyphName(value)
|
||||||
setattr(self, name, value)
|
setattr(self, name, value)
|
||||||
else:
|
else:
|
||||||
|
@ -37,7 +37,7 @@ class DefaultTable:
|
|||||||
return "<'%s' table at %x>" % (self.tableTag, id(self))
|
return "<'%s' table at %x>" % (self.tableTag, id(self))
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
return cmp(self.__dict__, other.__dict__)
|
return cmp(self.__dict__, other.__dict__)
|
||||||
|
@ -155,7 +155,7 @@ class table_E_B_D_T_(DefaultTable.DefaultTable):
|
|||||||
|
|
||||||
bitmapGlyphDict = {}
|
bitmapGlyphDict = {}
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name[4:].startswith(_bitmapGlyphSubclassPrefix[4:]):
|
if name[4:].startswith(_bitmapGlyphSubclassPrefix[4:]):
|
||||||
@ -191,7 +191,7 @@ class EbdtComponent:
|
|||||||
self.name = attrs['name']
|
self.name = attrs['name']
|
||||||
componentNames = set(sstruct.getformat(ebdtComponentFormat)[1][1:])
|
componentNames = set(sstruct.getformat(ebdtComponentFormat)[1][1:])
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name in componentNames:
|
if name in componentNames:
|
||||||
@ -287,7 +287,7 @@ def _readRowImageData(bitmapObject, name, attrs, content, ttFont):
|
|||||||
|
|
||||||
dataRows = []
|
dataRows = []
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attr, content = element
|
name, attr, content = element
|
||||||
# Chop off 'imagedata' from the tag to get just the option.
|
# Chop off 'imagedata' from the tag to get just the option.
|
||||||
@ -328,7 +328,7 @@ def _readBitwiseImageData(bitmapObject, name, attrs, content, ttFont):
|
|||||||
|
|
||||||
dataRows = []
|
dataRows = []
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attr, content = element
|
name, attr, content = element
|
||||||
if name == 'row':
|
if name == 'row':
|
||||||
@ -415,7 +415,7 @@ class BitmapGlyph:
|
|||||||
def fromXML(self, name, attrs, content, ttFont):
|
def fromXML(self, name, attrs, content, ttFont):
|
||||||
self.readMetrics(name, attrs, content, ttFont)
|
self.readMetrics(name, attrs, content, ttFont)
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attr, content = element
|
name, attr, content = element
|
||||||
# Chop off 'imagedata' from the tag to get just the option.
|
# Chop off 'imagedata' from the tag to get just the option.
|
||||||
@ -464,7 +464,7 @@ def _createBitmapPlusMetricsMixin(metricsClass):
|
|||||||
|
|
||||||
def readMetrics(self, name, attrs, content, ttFont):
|
def readMetrics(self, name, attrs, content, ttFont):
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name == curMetricsName:
|
if name == curMetricsName:
|
||||||
@ -671,13 +671,13 @@ class ComponentBitmapGlyph(BitmapGlyph):
|
|||||||
def fromXML(self, name, attrs, content, ttFont):
|
def fromXML(self, name, attrs, content, ttFont):
|
||||||
self.readMetrics(name, attrs, content, ttFont)
|
self.readMetrics(name, attrs, content, ttFont)
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attr, content = element
|
name, attr, content = element
|
||||||
if name == 'components':
|
if name == 'components':
|
||||||
self.componentArray = []
|
self.componentArray = []
|
||||||
for compElement in content:
|
for compElement in content:
|
||||||
if type(compElement) != TupleType:
|
if not isinstance(compElement, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = compElement
|
name, attrs, content = compElement
|
||||||
if name == 'ebdtComponent':
|
if name == 'ebdtComponent':
|
||||||
|
@ -242,7 +242,7 @@ class Strike:
|
|||||||
|
|
||||||
def fromXML(self, name, attrs, content, ttFont, locator):
|
def fromXML(self, name, attrs, content, ttFont, locator):
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name == 'bitmapSizeTable':
|
if name == 'bitmapSizeTable':
|
||||||
@ -282,7 +282,7 @@ class BitmapSizeTable:
|
|||||||
# bitmap size table. Only read the information from these names.
|
# bitmap size table. Only read the information from these names.
|
||||||
dataNames = set(self._getXMLMetricNames())
|
dataNames = set(self._getXMLMetricNames())
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name == 'sbitLineMetrics':
|
if name == 'sbitLineMetrics':
|
||||||
@ -311,7 +311,7 @@ class SbitLineMetrics:
|
|||||||
def fromXML(self, name, attrs, content, ttFont):
|
def fromXML(self, name, attrs, content, ttFont):
|
||||||
metricNames = set(sstruct.getformat(sbitLineMetricsFormat)[1])
|
metricNames = set(sstruct.getformat(sbitLineMetricsFormat)[1])
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name in metricNames:
|
if name in metricNames:
|
||||||
@ -378,7 +378,7 @@ class EblcIndexSubTable:
|
|||||||
|
|
||||||
self.names = []
|
self.names = []
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name == 'glyphLoc':
|
if name == 'glyphLoc':
|
||||||
@ -494,7 +494,7 @@ class FixedSizeIndexSubTableMixin:
|
|||||||
|
|
||||||
def readMetrics(self, name, attrs, content, ttFont):
|
def readMetrics(self, name, attrs, content, ttFont):
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name == 'imageSize':
|
if name == 'imageSize':
|
||||||
|
@ -35,8 +35,7 @@ class table_L_T_S_H_(DefaultTable.DefaultTable):
|
|||||||
return struct.pack(">HH", version, numGlyphs) + yPels.tostring()
|
return struct.pack(">HH", version, numGlyphs) + yPels.tostring()
|
||||||
|
|
||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
names = self.yPels.keys()
|
names = sorted(self.yPels.keys())
|
||||||
names.sort()
|
|
||||||
for name in names:
|
for name in names:
|
||||||
writer.simpletag("yPel", name=name, value=self.yPels[name])
|
writer.simpletag("yPel", name=name, value=self.yPels[name])
|
||||||
writer.newline()
|
writer.newline()
|
||||||
|
@ -229,7 +229,7 @@ class GlyphRecord:
|
|||||||
"""Compare method, so a list of NameRecords can be sorted
|
"""Compare method, so a list of NameRecords can be sorted
|
||||||
according to the spec by just sorting it..."""
|
according to the spec by just sorting it..."""
|
||||||
|
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
return cmp(self.glyphID, other.glyphID)
|
return cmp(self.glyphID, other.glyphID)
|
||||||
@ -314,7 +314,7 @@ class StringRecord:
|
|||||||
"""Compare method, so a list of NameRecords can be sorted
|
"""Compare method, so a list of NameRecords can be sorted
|
||||||
according to the spec by just sorting it..."""
|
according to the spec by just sorting it..."""
|
||||||
|
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
return cmp(self.labelID, other.labelID)
|
return cmp(self.labelID, other.labelID)
|
||||||
|
@ -172,7 +172,7 @@ class table_O_S_2f_2(DefaultTable.DefaultTable):
|
|||||||
if name == "panose":
|
if name == "panose":
|
||||||
self.panose = panose = Panose()
|
self.panose = panose = Panose()
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) == TupleType:
|
if isinstance(element, TupleType):
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
panose.fromXML(name, attrs, content, ttFont)
|
panose.fromXML(name, attrs, content, ttFont)
|
||||||
elif name in ("ulUnicodeRange1", "ulUnicodeRange2",
|
elif name in ("ulUnicodeRange1", "ulUnicodeRange2",
|
||||||
|
@ -327,7 +327,7 @@ class ColorPalettes:
|
|||||||
|
|
||||||
def fromXML(self, name, attrs, content, ttFont):
|
def fromXML(self, name, attrs, content, ttFont):
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) == type(""):
|
if isinstance(element, type("")):
|
||||||
continue
|
continue
|
||||||
name, attrib, content = element
|
name, attrib, content = element
|
||||||
if name == "colorParamUINameID":
|
if name == "colorParamUINameID":
|
||||||
@ -352,7 +352,7 @@ class ColorPalette:
|
|||||||
def fromXML(self, name, attrs, content, ttFont):
|
def fromXML(self, name, attrs, content, ttFont):
|
||||||
self.uiNameID = int(attrs["uiNameID"])
|
self.uiNameID = int(attrs["uiNameID"])
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) == type(""):
|
if isinstance(element, type("")):
|
||||||
continue
|
continue
|
||||||
name, attrib, content = element
|
name, attrib, content = element
|
||||||
if name == "colorRecord":
|
if name == "colorRecord":
|
||||||
|
@ -59,8 +59,7 @@ class table_T_S_I__1(DefaultTable.DefaultTable):
|
|||||||
data = data + text
|
data = data + text
|
||||||
|
|
||||||
extra_indices = []
|
extra_indices = []
|
||||||
codes = self.extras.items()
|
codes = sorted(self.extras.items())
|
||||||
codes.sort()
|
|
||||||
for i in range(len(codes)):
|
for i in range(len(codes)):
|
||||||
if len(data) % 2:
|
if len(data) % 2:
|
||||||
data = data + "\015" # align on 2-byte boundaries, fill with return chars.
|
data = data + "\015" # align on 2-byte boundaries, fill with return chars.
|
||||||
@ -78,8 +77,7 @@ class table_T_S_I__1(DefaultTable.DefaultTable):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
names = self.glyphPrograms.keys()
|
names = sorted(self.glyphPrograms.keys())
|
||||||
names.sort()
|
|
||||||
writer.newline()
|
writer.newline()
|
||||||
for name in names:
|
for name in names:
|
||||||
text = self.glyphPrograms[name]
|
text = self.glyphPrograms[name]
|
||||||
|
@ -28,8 +28,7 @@ class table_T_S_I__5(DefaultTable.DefaultTable):
|
|||||||
return a.tostring()
|
return a.tostring()
|
||||||
|
|
||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
names = self.glyphGrouping.keys()
|
names = sorted(self.glyphGrouping.keys())
|
||||||
names.sort()
|
|
||||||
for glyphName in names:
|
for glyphName in names:
|
||||||
writer.simpletag("glyphgroup", name=glyphName, value=self.glyphGrouping[glyphName])
|
writer.simpletag("glyphgroup", name=glyphName, value=self.glyphGrouping[glyphName])
|
||||||
writer.newline()
|
writer.newline()
|
||||||
|
@ -96,7 +96,7 @@ class table_V_O_R_G_(DefaultTable.DefaultTable):
|
|||||||
|
|
||||||
|
|
||||||
def __getitem__(self, glyphSelector):
|
def __getitem__(self, glyphSelector):
|
||||||
if type(glyphSelector) == IntType:
|
if isinstance(glyphSelector, IntType):
|
||||||
# its a gid, convert to glyph name
|
# its a gid, convert to glyph name
|
||||||
glyphSelector = self.getGlyphName(glyphSelector)
|
glyphSelector = self.getGlyphName(glyphSelector)
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ class table_V_O_R_G_(DefaultTable.DefaultTable):
|
|||||||
return self.VOriginRecords[glyphSelector]
|
return self.VOriginRecords[glyphSelector]
|
||||||
|
|
||||||
def __setitem__(self, glyphSelector, value):
|
def __setitem__(self, glyphSelector, value):
|
||||||
if type(glyphSelector) == IntType:
|
if isinstance(glyphSelector, IntType):
|
||||||
# its a gid, convert to glyph name
|
# its a gid, convert to glyph name
|
||||||
glyphSelector = self.getGlyphName(glyphSelector)
|
glyphSelector = self.getGlyphName(glyphSelector)
|
||||||
|
|
||||||
|
@ -132,8 +132,7 @@ class CmapSubtable:
|
|||||||
("language", self.language),
|
("language", self.language),
|
||||||
])
|
])
|
||||||
writer.newline()
|
writer.newline()
|
||||||
codes = self.cmap.items()
|
codes = sorted(self.cmap.items())
|
||||||
codes.sort()
|
|
||||||
self._writeCodes(codes, writer)
|
self._writeCodes(codes, writer)
|
||||||
writer.endtag(self.__class__.__name__)
|
writer.endtag(self.__class__.__name__)
|
||||||
writer.newline()
|
writer.newline()
|
||||||
@ -151,7 +150,7 @@ class CmapSubtable:
|
|||||||
writer.newline()
|
writer.newline()
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
|
|
||||||
# implemented so that list.sort() sorts according to the cmap spec.
|
# implemented so that list.sort() sorts according to the cmap spec.
|
||||||
selfTuple = (
|
selfTuple = (
|
||||||
@ -191,8 +190,7 @@ class cmap_format_0(CmapSubtable):
|
|||||||
if self.data:
|
if self.data:
|
||||||
return struct.pack(">HHH", 0, 262, self.language) + self.data
|
return struct.pack(">HHH", 0, 262, self.language) + self.data
|
||||||
|
|
||||||
charCodeList = self.cmap.items()
|
charCodeList = sorted(self.cmap.items())
|
||||||
charCodeList.sort()
|
|
||||||
charCodes = [entry[0] for entry in charCodeList]
|
charCodes = [entry[0] for entry in charCodeList]
|
||||||
valueList = [entry[1] for entry in charCodeList]
|
valueList = [entry[1] for entry in charCodeList]
|
||||||
assert charCodes == list(range(256))
|
assert charCodes == list(range(256))
|
||||||
@ -209,7 +207,7 @@ class cmap_format_0(CmapSubtable):
|
|||||||
self.cmap = {}
|
self.cmap = {}
|
||||||
cmap = self.cmap
|
cmap = self.cmap
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name != "map":
|
if name != "map":
|
||||||
@ -380,8 +378,7 @@ class cmap_format_2(CmapSubtable):
|
|||||||
kEmptyTwoCharCodeRange = -1
|
kEmptyTwoCharCodeRange = -1
|
||||||
notdefGI = 0
|
notdefGI = 0
|
||||||
|
|
||||||
items = self.cmap.items()
|
items = sorted(self.cmap.items())
|
||||||
items.sort()
|
|
||||||
charCodes = [item[0] for item in items]
|
charCodes = [item[0] for item in items]
|
||||||
names = [item[1] for item in items]
|
names = [item[1] for item in items]
|
||||||
nameMap = ttFont.getReverseGlyphMap()
|
nameMap = ttFont.getReverseGlyphMap()
|
||||||
@ -529,7 +526,7 @@ class cmap_format_2(CmapSubtable):
|
|||||||
cmap = self.cmap
|
cmap = self.cmap
|
||||||
|
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name != "map":
|
if name != "map":
|
||||||
@ -821,7 +818,7 @@ class cmap_format_4(CmapSubtable):
|
|||||||
cmap = self.cmap
|
cmap = self.cmap
|
||||||
|
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
nameMap, attrsMap, dummyContent = element
|
nameMap, attrsMap, dummyContent = element
|
||||||
if nameMap != "map":
|
if nameMap != "map":
|
||||||
@ -890,7 +887,7 @@ class cmap_format_6(CmapSubtable):
|
|||||||
cmap = self.cmap
|
cmap = self.cmap
|
||||||
|
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name != "map":
|
if name != "map":
|
||||||
@ -1016,8 +1013,7 @@ class cmap_format_12_or_13(CmapSubtable):
|
|||||||
("nGroups", self.nGroups),
|
("nGroups", self.nGroups),
|
||||||
])
|
])
|
||||||
writer.newline()
|
writer.newline()
|
||||||
codes = self.cmap.items()
|
codes = sorted(self.cmap.items())
|
||||||
codes.sort()
|
|
||||||
self._writeCodes(codes, writer)
|
self._writeCodes(codes, writer)
|
||||||
writer.endtag(self.__class__.__name__)
|
writer.endtag(self.__class__.__name__)
|
||||||
writer.newline()
|
writer.newline()
|
||||||
@ -1033,7 +1029,7 @@ class cmap_format_12_or_13(CmapSubtable):
|
|||||||
cmap = self.cmap
|
cmap = self.cmap
|
||||||
|
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name != "map":
|
if name != "map":
|
||||||
@ -1164,8 +1160,7 @@ class cmap_format_14(CmapSubtable):
|
|||||||
])
|
])
|
||||||
writer.newline()
|
writer.newline()
|
||||||
uvsDict = self.uvsDict
|
uvsDict = self.uvsDict
|
||||||
uvsList = uvsDict.keys()
|
uvsList = sorted(uvsDict.keys())
|
||||||
uvsList.sort()
|
|
||||||
for uvs in uvsList:
|
for uvs in uvsList:
|
||||||
uvList = uvsDict[uvs]
|
uvList = uvsDict[uvs]
|
||||||
uvList.sort(cmpUVSListEntry)
|
uvList.sort(cmpUVSListEntry)
|
||||||
@ -1190,7 +1185,7 @@ class cmap_format_14(CmapSubtable):
|
|||||||
uvsDict = self.uvsDict
|
uvsDict = self.uvsDict
|
||||||
|
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name != "map":
|
if name != "map":
|
||||||
@ -1211,8 +1206,7 @@ class cmap_format_14(CmapSubtable):
|
|||||||
return struct.pack(">HLL", self.format, self.length , self.numVarSelectorRecords) + self.data
|
return struct.pack(">HLL", self.format, self.length , self.numVarSelectorRecords) + self.data
|
||||||
|
|
||||||
uvsDict = self.uvsDict
|
uvsDict = self.uvsDict
|
||||||
uvsList = uvsDict.keys()
|
uvsList = sorted(uvsDict.keys())
|
||||||
uvsList.sort()
|
|
||||||
self.numVarSelectorRecords = len(uvsList)
|
self.numVarSelectorRecords = len(uvsList)
|
||||||
offset = 10 + self.numVarSelectorRecords*11 # current value is end of VarSelectorRecords block.
|
offset = 10 + self.numVarSelectorRecords*11 # current value is end of VarSelectorRecords block.
|
||||||
data = []
|
data = []
|
||||||
|
@ -25,8 +25,7 @@ class table__g_a_s_p(DefaultTable.DefaultTable):
|
|||||||
version = 0 # ignore self.version
|
version = 0 # ignore self.version
|
||||||
numRanges = len(self.gaspRange)
|
numRanges = len(self.gaspRange)
|
||||||
data = ""
|
data = ""
|
||||||
items = self.gaspRange.items()
|
items = sorted(self.gaspRange.items())
|
||||||
items.sort()
|
|
||||||
for rangeMaxPPEM, rangeGaspBehavior in items:
|
for rangeMaxPPEM, rangeGaspBehavior in items:
|
||||||
data = data + struct.pack(">HH", rangeMaxPPEM, rangeGaspBehavior)
|
data = data + struct.pack(">HH", rangeMaxPPEM, rangeGaspBehavior)
|
||||||
if rangeGaspBehavior & ~(GASP_GRIDFIT | GASP_DOGRAY):
|
if rangeGaspBehavior & ~(GASP_GRIDFIT | GASP_DOGRAY):
|
||||||
@ -35,8 +34,7 @@ class table__g_a_s_p(DefaultTable.DefaultTable):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
items = self.gaspRange.items()
|
items = sorted(self.gaspRange.items())
|
||||||
items.sort()
|
|
||||||
for rangeMaxPPEM, rangeGaspBehavior in items:
|
for rangeMaxPPEM, rangeGaspBehavior in items:
|
||||||
writer.simpletag("gaspRange", [
|
writer.simpletag("gaspRange", [
|
||||||
("rangeMaxPPEM", rangeMaxPPEM),
|
("rangeMaxPPEM", rangeMaxPPEM),
|
||||||
|
@ -124,7 +124,7 @@ class table__g_l_y_f(DefaultTable.DefaultTable):
|
|||||||
setattr(glyph, attr, safeEval(attrs.get(attr, '0')))
|
setattr(glyph, attr, safeEval(attrs.get(attr, '0')))
|
||||||
self.glyphs[glyphName] = glyph
|
self.glyphs[glyphName] = glyph
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
glyph.fromXML(name, attrs, content, ttFont)
|
glyph.fromXML(name, attrs, content, ttFont)
|
||||||
@ -290,7 +290,7 @@ class Glyph:
|
|||||||
coordinates = GlyphCoordinates()
|
coordinates = GlyphCoordinates()
|
||||||
flags = []
|
flags = []
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name != "pt":
|
if name != "pt":
|
||||||
@ -318,7 +318,7 @@ class Glyph:
|
|||||||
elif name == "instructions":
|
elif name == "instructions":
|
||||||
self.program = ttProgram.Program()
|
self.program = ttProgram.Program()
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
self.program.fromXML(name, attrs, content, ttFont)
|
self.program.fromXML(name, attrs, content, ttFont)
|
||||||
@ -425,7 +425,7 @@ class Glyph:
|
|||||||
xFormat = ">" # big endian
|
xFormat = ">" # big endian
|
||||||
yFormat = ">" # big endian
|
yFormat = ">" # big endian
|
||||||
i = j = 0
|
i = j = 0
|
||||||
while 1:
|
while True:
|
||||||
flag = ord(data[i])
|
flag = ord(data[i])
|
||||||
i = i + 1
|
i = i + 1
|
||||||
repeat = 1
|
repeat = 1
|
||||||
@ -672,7 +672,7 @@ class Glyph:
|
|||||||
# padding.
|
# padding.
|
||||||
coordBytes = 0
|
coordBytes = 0
|
||||||
j = 0
|
j = 0
|
||||||
while 1:
|
while True:
|
||||||
flag = data[i]
|
flag = data[i]
|
||||||
i = i + 1
|
i = i + 1
|
||||||
repeat = 1
|
repeat = 1
|
||||||
@ -725,7 +725,7 @@ class Glyph:
|
|||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
return cmp(self.__dict__, other.__dict__)
|
return cmp(self.__dict__, other.__dict__)
|
||||||
@ -888,7 +888,7 @@ class GlyphComponent:
|
|||||||
self.flags = safeEval(attrs["flags"])
|
self.flags = safeEval(attrs["flags"])
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
return cmp(self.__dict__, other.__dict__)
|
return cmp(self.__dict__, other.__dict__)
|
||||||
@ -971,7 +971,7 @@ class GlyphCoordinates:
|
|||||||
|
|
||||||
def reprflag(flag):
|
def reprflag(flag):
|
||||||
bin = ""
|
bin = ""
|
||||||
if type(flag) == StringType:
|
if isinstance(flag, StringType):
|
||||||
flag = ord(flag)
|
flag = ord(flag)
|
||||||
while flag:
|
while flag:
|
||||||
if flag & 0x01:
|
if flag & 0x01:
|
||||||
|
@ -34,8 +34,7 @@ class table__h_d_m_x(DefaultTable.DefaultTable):
|
|||||||
pad = (self.recordSize - 2 - numGlyphs) * "\0"
|
pad = (self.recordSize - 2 - numGlyphs) * "\0"
|
||||||
self.numRecords = len(self.hdmx)
|
self.numRecords = len(self.hdmx)
|
||||||
data = sstruct.pack(hdmxHeaderFormat, self)
|
data = sstruct.pack(hdmxHeaderFormat, self)
|
||||||
items = self.hdmx.items()
|
items = sorted(self.hdmx.items())
|
||||||
items.sort()
|
|
||||||
for ppem, widths in items:
|
for ppem, widths in items:
|
||||||
data = data + chr(ppem) + chr(max(widths.values()))
|
data = data + chr(ppem) + chr(max(widths.values()))
|
||||||
for glyphID in range(len(glyphOrder)):
|
for glyphID in range(len(glyphOrder)):
|
||||||
@ -47,8 +46,7 @@ class table__h_d_m_x(DefaultTable.DefaultTable):
|
|||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
writer.begintag("hdmxData")
|
writer.begintag("hdmxData")
|
||||||
writer.newline()
|
writer.newline()
|
||||||
ppems = self.hdmx.keys()
|
ppems = sorted(self.hdmx.keys())
|
||||||
ppems.sort()
|
|
||||||
records = []
|
records = []
|
||||||
format = ""
|
format = ""
|
||||||
for ppem in ppems:
|
for ppem in ppems:
|
||||||
|
@ -87,7 +87,7 @@ class table__h_e_a_d(DefaultTable.DefaultTable):
|
|||||||
setattr(self, name, value)
|
setattr(self, name, value)
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
selfdict = self.__dict__.copy()
|
selfdict = self.__dict__.copy()
|
||||||
|
@ -72,8 +72,7 @@ class table__h_m_t_x(DefaultTable.DefaultTable):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
names = self.metrics.keys()
|
names = sorted(self.metrics.keys())
|
||||||
names.sort()
|
|
||||||
for glyphName in names:
|
for glyphName in names:
|
||||||
advance, sb = self.metrics[glyphName]
|
advance, sb = self.metrics[glyphName]
|
||||||
writer.simpletag("mtx", [
|
writer.simpletag("mtx", [
|
||||||
|
@ -120,10 +120,9 @@ class KernTable_format_0:
|
|||||||
data = struct.pack(">HHHH", nPairs, searchRange, entrySelector, rangeShift)
|
data = struct.pack(">HHHH", nPairs, searchRange, entrySelector, rangeShift)
|
||||||
|
|
||||||
# yeehee! (I mean, turn names into indices)
|
# yeehee! (I mean, turn names into indices)
|
||||||
kernTable = map(lambda ((left, right), value), getGlyphID=ttFont.getGlyphID:
|
kernTable = sorted(map(lambda ((left, right), value), getGlyphID=ttFont.getGlyphID:
|
||||||
(getGlyphID(left), getGlyphID(right), value),
|
(getGlyphID(left), getGlyphID(right), value),
|
||||||
self.kernTable.items())
|
self.kernTable.items()))
|
||||||
kernTable.sort()
|
|
||||||
for left, right, value in kernTable:
|
for left, right, value in kernTable:
|
||||||
data = data + struct.pack(">HHh", left, right, value)
|
data = data + struct.pack(">HHh", left, right, value)
|
||||||
return struct.pack(">HHH", self.version, len(data) + 6, self.coverage) + data
|
return struct.pack(">HHH", self.version, len(data) + 6, self.coverage) + data
|
||||||
@ -131,8 +130,7 @@ class KernTable_format_0:
|
|||||||
def toXML(self, writer, ttFont):
|
def toXML(self, writer, ttFont):
|
||||||
writer.begintag("kernsubtable", coverage=self.coverage, format=0)
|
writer.begintag("kernsubtable", coverage=self.coverage, format=0)
|
||||||
writer.newline()
|
writer.newline()
|
||||||
items = self.kernTable.items()
|
items = sorted(self.kernTable.items())
|
||||||
items.sort()
|
|
||||||
for (left, right), value in items:
|
for (left, right), value in items:
|
||||||
writer.simpletag("pair", [
|
writer.simpletag("pair", [
|
||||||
("l", left),
|
("l", left),
|
||||||
@ -149,7 +147,7 @@ class KernTable_format_0:
|
|||||||
if not hasattr(self, "kernTable"):
|
if not hasattr(self, "kernTable"):
|
||||||
self.kernTable = {}
|
self.kernTable = {}
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
self.kernTable[(attrs["l"], attrs["r"])] = safeEval(attrs["v"])
|
self.kernTable[(attrs["l"], attrs["r"])] = safeEval(attrs["v"])
|
||||||
@ -164,7 +162,7 @@ class KernTable_format_0:
|
|||||||
del self.kernTable[pair]
|
del self.kernTable[pair]
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
return cmp(self.__dict__, other.__dict__)
|
return cmp(self.__dict__, other.__dict__)
|
||||||
|
@ -60,7 +60,7 @@ class table__l_o_c_a(DefaultTable.DefaultTable):
|
|||||||
return len(self.locations)
|
return len(self.locations)
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
return cmp(self.locations, other.locations)
|
return cmp(self.locations, other.locations)
|
||||||
|
@ -112,8 +112,7 @@ class table__m_a_x_p(DefaultTable.DefaultTable):
|
|||||||
headTable.flags = headTable.flags & ~0x2
|
headTable.flags = headTable.flags & ~0x2
|
||||||
|
|
||||||
def testrepr(self):
|
def testrepr(self):
|
||||||
items = self.__dict__.items()
|
items = sorted(self.__dict__.items())
|
||||||
items.sort()
|
|
||||||
print ". . . . . . . . ."
|
print ". . . . . . . . ."
|
||||||
for combo in items:
|
for combo in items:
|
||||||
print " %s: %s" % combo
|
print " %s: %s" % combo
|
||||||
|
@ -89,7 +89,7 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
|
|||||||
return None # not found
|
return None # not found
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
return cmp(self.names, other.names)
|
return cmp(self.names, other.names)
|
||||||
@ -138,7 +138,7 @@ class NameRecord:
|
|||||||
"""Compare method, so a list of NameRecords can be sorted
|
"""Compare method, so a list of NameRecords can be sorted
|
||||||
according to the spec by just sorting it..."""
|
according to the spec by just sorting it..."""
|
||||||
|
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
|
|
||||||
selftuple = (
|
selftuple = (
|
||||||
getattr(self, "platformID", None),
|
getattr(self, "platformID", None),
|
||||||
|
@ -165,8 +165,7 @@ class table__p_o_s_t(DefaultTable.DefaultTable):
|
|||||||
"ps name mapping for those cases where they differ. That's what\n"
|
"ps name mapping for those cases where they differ. That's what\n"
|
||||||
"you see below.\n")
|
"you see below.\n")
|
||||||
writer.newline()
|
writer.newline()
|
||||||
items = self.mapping.items()
|
items = sorted(self.mapping.items())
|
||||||
items.sort()
|
|
||||||
for name, psName in items:
|
for name, psName in items:
|
||||||
writer.simpletag("psName", name=name, psName=psName)
|
writer.simpletag("psName", name=name, psName=psName)
|
||||||
writer.newline()
|
writer.newline()
|
||||||
@ -195,7 +194,7 @@ class table__p_o_s_t(DefaultTable.DefaultTable):
|
|||||||
elif name == "psNames":
|
elif name == "psNames":
|
||||||
self.mapping = {}
|
self.mapping = {}
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name == "psName":
|
if name == "psName":
|
||||||
@ -203,7 +202,7 @@ class table__p_o_s_t(DefaultTable.DefaultTable):
|
|||||||
elif name == "extraNames":
|
elif name == "extraNames":
|
||||||
self.extraNames = []
|
self.extraNames = []
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
if name == "psName":
|
if name == "psName":
|
||||||
|
@ -43,8 +43,7 @@ class BaseTTXConverter(DefaultTable):
|
|||||||
self.table = tableClass()
|
self.table = tableClass()
|
||||||
self.table.decompile(reader, font)
|
self.table.decompile(reader, font)
|
||||||
if cachingStats:
|
if cachingStats:
|
||||||
stats = [(v, k) for k, v in cachingStats.items()]
|
stats = sorted([(v, k) for k, v in cachingStats.items()])
|
||||||
stats.sort()
|
|
||||||
stats.reverse()
|
stats.reverse()
|
||||||
print "cachingsstats for ", self.tableTag
|
print "cachingsstats for ", self.tableTag
|
||||||
for v, k in stats:
|
for v, k in stats:
|
||||||
@ -289,7 +288,7 @@ class OTTableWriter(object):
|
|||||||
return hash(self.items)
|
return hash(self.items)
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
return cmp(self.items, other.items)
|
return cmp(self.items, other.items)
|
||||||
@ -675,7 +674,7 @@ class BaseTable(object):
|
|||||||
setattr(self, conv.name, value)
|
setattr(self, conv.name, value)
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
self.ensureDecompiled()
|
self.ensureDecompiled()
|
||||||
@ -829,19 +828,19 @@ class ValueRecord:
|
|||||||
for k, v in attrs.items():
|
for k, v in attrs.items():
|
||||||
setattr(self, k, int(v))
|
setattr(self, k, int(v))
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
value = getattr(otTables, name)()
|
value = getattr(otTables, name)()
|
||||||
for elem2 in content:
|
for elem2 in content:
|
||||||
if type(elem2) != TupleType:
|
if not isinstance(elem2, TupleType):
|
||||||
continue
|
continue
|
||||||
name2, attrs2, content2 = elem2
|
name2, attrs2, content2 = elem2
|
||||||
value.fromXML(name2, attrs2, content2, font)
|
value.fromXML(name2, attrs2, content2, font)
|
||||||
setattr(self, name, value)
|
setattr(self, name, value)
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
if type(self) != type(other): return cmp(type(self), type(other))
|
if not isinstance(self, type(other)): return cmp(type(self), type(other))
|
||||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||||
|
|
||||||
return cmp(self.__dict__, other.__dict__)
|
return cmp(self.__dict__, other.__dict__)
|
||||||
|
@ -198,7 +198,7 @@ class Struct(BaseConverter):
|
|||||||
if Format is not None:
|
if Format is not None:
|
||||||
table.Format = int(Format)
|
table.Format = int(Format)
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) == TupleType:
|
if isinstance(element, TupleType):
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
table.fromXML(name, attrs, content, font)
|
table.fromXML(name, attrs, content, font)
|
||||||
else:
|
else:
|
||||||
|
@ -163,8 +163,7 @@ class SingleSubst(FormatSwitchingBaseTable):
|
|||||||
items = mapping.items()
|
items = mapping.items()
|
||||||
getGlyphID = font.getGlyphID
|
getGlyphID = font.getGlyphID
|
||||||
gidItems = [(getGlyphID(item[0]), getGlyphID(item[1])) for item in items]
|
gidItems = [(getGlyphID(item[0]), getGlyphID(item[1])) for item in items]
|
||||||
sortableItems = list(zip(gidItems, items))
|
sortableItems = sorted(zip(gidItems, items))
|
||||||
sortableItems.sort()
|
|
||||||
|
|
||||||
# figure out format
|
# figure out format
|
||||||
format = 2
|
format = 2
|
||||||
@ -193,8 +192,7 @@ class SingleSubst(FormatSwitchingBaseTable):
|
|||||||
return rawTable
|
return rawTable
|
||||||
|
|
||||||
def toXML2(self, xmlWriter, font):
|
def toXML2(self, xmlWriter, font):
|
||||||
items = self.mapping.items()
|
items = sorted(self.mapping.items())
|
||||||
items.sort()
|
|
||||||
for inGlyph, outGlyph in items:
|
for inGlyph, outGlyph in items:
|
||||||
xmlWriter.simpletag("Substitution",
|
xmlWriter.simpletag("Substitution",
|
||||||
[("in", inGlyph), ("out", outGlyph)])
|
[("in", inGlyph), ("out", outGlyph)])
|
||||||
@ -273,8 +271,7 @@ class ClassDef(FormatSwitchingBaseTable):
|
|||||||
return {"ClassRangeRecord": ranges}
|
return {"ClassRangeRecord": ranges}
|
||||||
|
|
||||||
def toXML2(self, xmlWriter, font):
|
def toXML2(self, xmlWriter, font):
|
||||||
items = self.classDefs.items()
|
items = sorted(self.classDefs.items())
|
||||||
items.sort()
|
|
||||||
for glyphName, cls in items:
|
for glyphName, cls in items:
|
||||||
xmlWriter.simpletag("ClassDef", [("glyph", glyphName), ("class", cls)])
|
xmlWriter.simpletag("ClassDef", [("glyph", glyphName), ("class", cls)])
|
||||||
xmlWriter.newline()
|
xmlWriter.newline()
|
||||||
@ -329,8 +326,7 @@ class AlternateSubst(FormatSwitchingBaseTable):
|
|||||||
return {"Coverage": cov, "AlternateSet": alternates}
|
return {"Coverage": cov, "AlternateSet": alternates}
|
||||||
|
|
||||||
def toXML2(self, xmlWriter, font):
|
def toXML2(self, xmlWriter, font):
|
||||||
items = self.alternates.items()
|
items = sorted(self.alternates.items())
|
||||||
items.sort()
|
|
||||||
for glyphName, alternates in items:
|
for glyphName, alternates in items:
|
||||||
xmlWriter.begintag("AlternateSet", glyph=glyphName)
|
xmlWriter.begintag("AlternateSet", glyph=glyphName)
|
||||||
xmlWriter.newline()
|
xmlWriter.newline()
|
||||||
@ -349,7 +345,7 @@ class AlternateSubst(FormatSwitchingBaseTable):
|
|||||||
set = []
|
set = []
|
||||||
alternates[glyphName] = set
|
alternates[glyphName] = set
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
set.append(attrs["glyph"])
|
set.append(attrs["glyph"])
|
||||||
@ -396,8 +392,7 @@ class LigatureSubst(FormatSwitchingBaseTable):
|
|||||||
return {"Coverage": cov, "LigatureSet": ligSets}
|
return {"Coverage": cov, "LigatureSet": ligSets}
|
||||||
|
|
||||||
def toXML2(self, xmlWriter, font):
|
def toXML2(self, xmlWriter, font):
|
||||||
items = self.ligatures.items()
|
items = sorted(self.ligatures.items())
|
||||||
items.sort()
|
|
||||||
for glyphName, ligSets in items:
|
for glyphName, ligSets in items:
|
||||||
xmlWriter.begintag("LigatureSet", glyph=glyphName)
|
xmlWriter.begintag("LigatureSet", glyph=glyphName)
|
||||||
xmlWriter.newline()
|
xmlWriter.newline()
|
||||||
@ -417,7 +412,7 @@ class LigatureSubst(FormatSwitchingBaseTable):
|
|||||||
ligs = []
|
ligs = []
|
||||||
ligatures[glyphName] = ligs
|
ligatures[glyphName] = ligs
|
||||||
for element in content:
|
for element in content:
|
||||||
if type(element) != TupleType:
|
if not isinstance(element, TupleType):
|
||||||
continue
|
continue
|
||||||
name, attrs, content = element
|
name, attrs, content = element
|
||||||
lig = Ligature()
|
lig = Ligature()
|
||||||
@ -523,8 +518,7 @@ def splitAlternateSubst(oldSubTable, newSubTable, overflowRecord):
|
|||||||
if hasattr(oldSubTable, 'sortCoverageLast'):
|
if hasattr(oldSubTable, 'sortCoverageLast'):
|
||||||
newSubTable.sortCoverageLast = oldSubTable.sortCoverageLast
|
newSubTable.sortCoverageLast = oldSubTable.sortCoverageLast
|
||||||
|
|
||||||
oldAlts = oldSubTable.alternates.items()
|
oldAlts = sorted(oldSubTable.alternates.items())
|
||||||
oldAlts.sort()
|
|
||||||
oldLen = len(oldAlts)
|
oldLen = len(oldAlts)
|
||||||
|
|
||||||
if overflowRecord.itemName in [ 'Coverage', 'RangeRecord']:
|
if overflowRecord.itemName in [ 'Coverage', 'RangeRecord']:
|
||||||
@ -552,8 +546,7 @@ def splitAlternateSubst(oldSubTable, newSubTable, overflowRecord):
|
|||||||
def splitLigatureSubst(oldSubTable, newSubTable, overflowRecord):
|
def splitLigatureSubst(oldSubTable, newSubTable, overflowRecord):
|
||||||
ok = 1
|
ok = 1
|
||||||
newSubTable.Format = oldSubTable.Format
|
newSubTable.Format = oldSubTable.Format
|
||||||
oldLigs = oldSubTable.ligatures.items()
|
oldLigs = sorted(oldSubTable.ligatures.items())
|
||||||
oldLigs.sort()
|
|
||||||
oldLen = len(oldLigs)
|
oldLen = len(oldLigs)
|
||||||
|
|
||||||
if overflowRecord.itemName in [ 'Coverage', 'RangeRecord']:
|
if overflowRecord.itemName in [ 'Coverage', 'RangeRecord']:
|
||||||
|
@ -269,7 +269,7 @@ class Program:
|
|||||||
skipWhite=_skipWhite, mnemonicDict=mnemonicDict, strip=string.strip,
|
skipWhite=_skipWhite, mnemonicDict=mnemonicDict, strip=string.strip,
|
||||||
binary2num=binary2num):
|
binary2num=binary2num):
|
||||||
assembly = self.assembly
|
assembly = self.assembly
|
||||||
if type(assembly) == type([]):
|
if isinstance(assembly, type([])):
|
||||||
assembly = string.join(assembly, " ")
|
assembly = string.join(assembly, " ")
|
||||||
bytecode = []
|
bytecode = []
|
||||||
push = bytecode.append
|
push = bytecode.append
|
||||||
|
@ -173,8 +173,7 @@ def ttList(input, output, options):
|
|||||||
import string
|
import string
|
||||||
ttf = TTFont(input, fontNumber=options.fontNumber, lazy=True)
|
ttf = TTFont(input, fontNumber=options.fontNumber, lazy=True)
|
||||||
reader = ttf.reader
|
reader = ttf.reader
|
||||||
tags = reader.keys()
|
tags = sorted(reader.keys())
|
||||||
tags.sort()
|
|
||||||
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")
|
||||||
@ -224,7 +223,7 @@ def ttCompile(input, output, options):
|
|||||||
overflowRecord = e.value
|
overflowRecord = e.value
|
||||||
print "Attempting to fix OTLOffsetOverflowError", e
|
print "Attempting to fix OTLOffsetOverflowError", e
|
||||||
lastItem = overflowRecord
|
lastItem = overflowRecord
|
||||||
while 1:
|
while True:
|
||||||
ok = 0
|
ok = 0
|
||||||
if overflowRecord.itemName == None:
|
if overflowRecord.itemName == None:
|
||||||
ok = fixLookupOverFlows(ttf, overflowRecord)
|
ok = fixLookupOverFlows(ttf, overflowRecord)
|
||||||
|
@ -46,7 +46,7 @@ def roundTrip(ttFile1, options, report):
|
|||||||
diffcmd = 'diff -U2 -I ".*modified value\|checkSumAdjustment.*" "%s" "%s"' % (xmlFile1, xmlFile2)
|
diffcmd = 'diff -U2 -I ".*modified value\|checkSumAdjustment.*" "%s" "%s"' % (xmlFile1, xmlFile2)
|
||||||
output = os.popen(diffcmd, "r", 1)
|
output = os.popen(diffcmd, "r", 1)
|
||||||
lines = []
|
lines = []
|
||||||
while 1:
|
while True:
|
||||||
line = output.readline()
|
line = output.readline()
|
||||||
if not line:
|
if not line:
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user