Use True/False instead of 1/0
diff --git a/Lib/fontTools/misc/arrayTools.py b/Lib/fontTools/misc/arrayTools.py
index f680578..c05e195 100644
--- a/Lib/fontTools/misc/arrayTools.py
+++ b/Lib/fontTools/misc/arrayTools.py
@@ -93,8 +93,8 @@
xMin, yMin, xMax, yMax = (max(xMin1, xMin2), max(yMin1, yMin2),
min(xMax1, xMax2), min(yMax1, yMax2))
if xMin >= xMax or yMin >= yMax:
- return 0, (0, 0, 0, 0)
- return 1, (xMin, yMin, xMax, yMax)
+ return False, (0, 0, 0, 0)
+ return True, (xMin, yMin, xMax, yMax)
def unionRect(rect1, rect2):
"""Return the smallest rectangle in which both input rectangles are fully
diff --git a/Lib/fontTools/subset.py b/Lib/fontTools/subset.py
index 3c77f06..99a19e9 100644
--- a/Lib/fontTools/subset.py
+++ b/Lib/fontTools/subset.py
@@ -2124,7 +2124,7 @@
elif g.startswith('glyph') and len(g) > 5:
g = g[5:]
try:
- glyphs.append(font.getGlyphName(int(g), requireReal=1))
+ glyphs.append(font.getGlyphName(int(g), requireReal=True))
except ValueError:
raise Exception("Invalid glyph identifier: %s" % g)
continue
diff --git a/Lib/fontTools/t1Lib.py b/Lib/fontTools/t1Lib.py
index 15825d2..aae86d9 100644
--- a/Lib/fontTools/t1Lib.py
+++ b/Lib/fontTools/t1Lib.py
@@ -8,7 +8,7 @@
to by 'path'.
Raises an error when the file does not contain valid Type 1 data.
-write(path, data, kind='OTHER', dohex=0)
+write(path, data, kind='OTHER', dohex=False)
writes raw Type 1 data to the file pointed to by 'path'.
'kind' can be one of 'LWFN', 'PFB' or 'OTHER'; it defaults to 'OTHER'.
'dohex' is a flag which determines whether the eexec encrypted
@@ -100,7 +100,7 @@
# low level T1 data read and write functions
-def read(path, onlyHeader=0):
+def read(path, onlyHeader=False):
"""reads any Type 1 font file, returns raw data"""
normpath = path.lower()
creator, typ = getMacCreatorAndType(path)
@@ -111,7 +111,7 @@
else:
return readOther(path), 'OTHER'
-def write(path, data, kind='OTHER', dohex=0):
+def write(path, data, kind='OTHER', dohex=False):
assertType1(data)
kind = kind.upper()
try:
@@ -141,7 +141,7 @@
HEXLINELENGTH = 80
-def readLWFN(path, onlyHeader=0):
+def readLWFN(path, onlyHeader=False):
"""reads an LWFN font file, returns raw data"""
resRef = Res.FSOpenResFile(path, 1) # read-only
try:
@@ -173,7 +173,7 @@
assertType1(data)
return data
-def readPFB(path, onlyHeader=0):
+def readPFB(path, onlyHeader=False):
"""reads a PFB font file, returns raw data"""
f = open(path, "rb")
data = []
@@ -253,7 +253,7 @@
finally:
f.close()
-def writeOther(path, data, dohex = 0):
+def writeOther(path, data, dohex=False):
chunks = findEncryptedChunks(data)
f = open(path, "wb")
try:
diff --git a/Lib/fontTools/ttLib/__init__.py b/Lib/fontTools/ttLib/__init__.py
index 06ed113..746f06e 100644
--- a/Lib/fontTools/ttLib/__init__.py
+++ b/Lib/fontTools/ttLib/__init__.py
@@ -70,8 +70,8 @@
"""
def __init__(self, file=None, res_name_or_index=None,
- sfntVersion="\000\001\000\000", flavor=None, checkChecksums=0,
- verbose=0, recalcBBoxes=1, allowVID=0, ignoreDecompileErrors=False,
+ sfntVersion="\000\001\000\000", flavor=None, checkChecksums=False,
+ verbose=False, recalcBBoxes=True, allowVID=False, ignoreDecompileErrors=False,
fontNumber=-1, lazy=True, quiet=False):
"""The constructor can be called with a few different arguments.
@@ -172,7 +172,7 @@
if self.reader is not None:
self.reader.close()
- def save(self, file, makeSuitcase=0, reorderTables=1):
+ def save(self, file, makeSuitcase=False, reorderTables=True):
"""Save the font to disk. Similarly to the constructor,
the 'file' argument can be either a pathname or a writable
file object.
@@ -342,13 +342,13 @@
def has_key(self, tag):
if self.isLoaded(tag):
- return 1
+ return True
elif self.reader and tag in self.reader:
- return 1
+ return True
elif tag == "GlyphOrder":
- return 1
+ return True
else:
- return 0
+ return False
__contains__ = has_key
@@ -529,7 +529,7 @@
from fontTools.misc import textTools
return textTools.caselessSort(self.getGlyphOrder())
- def getGlyphName(self, glyphID, requireReal=0):
+ def getGlyphName(self, glyphID, requireReal=False):
try:
return self.getGlyphOrder()[glyphID]
except IndexError:
@@ -548,7 +548,7 @@
self.VIDDict[glyphID] = glyphName
return glyphName
- def getGlyphID(self, glyphName, requireReal = 0):
+ def getGlyphID(self, glyphName, requireReal=False):
if not hasattr(self, "_reverseGlyphOrderDict"):
self._buildReverseGlyphOrderDict()
glyphOrder = self.getGlyphOrder()
@@ -584,7 +584,7 @@
return self.getGlyphID(glyphName)
return glyphID
- def getReverseGlyphMap(self, rebuild=0):
+ def getReverseGlyphMap(self, rebuild=False):
if rebuild or not hasattr(self, "_reverseGlyphOrderDict"):
self._buildReverseGlyphOrderDict()
return self._reverseGlyphOrderDict
@@ -629,7 +629,7 @@
else:
raise KeyError(tag)
- def getGlyphSet(self, preferCFF=1):
+ def getGlyphSet(self, preferCFF=True):
"""Return a generic GlyphSet, which is a dict-like object
mapping glyph names to glyph objects. The returned glyph objects
have a .draw() method that supports the Pen protocol, and will
@@ -933,7 +933,7 @@
return orderedTables
-def reorderFontTables(inFile, outFile, tableOrder=None, checkChecksums=0):
+def reorderFontTables(inFile, outFile, tableOrder=None, checkChecksums=False):
"""Rewrite a font file, ordering the tables as recommended by the
OpenType specification 1.4.
"""
diff --git a/Lib/fontTools/ttLib/tables/C_F_F_.py b/Lib/fontTools/ttLib/tables/C_F_F_.py
index eb48f75..6c86947 100644
--- a/Lib/fontTools/ttLib/tables/C_F_F_.py
+++ b/Lib/fontTools/ttLib/tables/C_F_F_.py
@@ -9,7 +9,7 @@
def __init__(self, tag):
DefaultTable.DefaultTable.__init__(self, tag)
self.cff = cffLib.CFFFontSet()
- self._gaveGlyphOrder = 0
+ self._gaveGlyphOrder = False
def decompile(self, data, otFont):
self.cff.decompile(StringIO(data), otFont)
@@ -22,15 +22,15 @@
def haveGlyphNames(self):
if hasattr(self.cff[self.cff.fontNames[0]], "ROS"):
- return 0 # CID-keyed font
+ return False # CID-keyed font
else:
- return 1
+ return True
def getGlyphOrder(self):
if self._gaveGlyphOrder:
from fontTools import ttLib
raise ttLib.TTLibError("illegal use of getGlyphOrder()")
- self._gaveGlyphOrder = 1
+ self._gaveGlyphOrder = True
return self.cff[self.cff.fontNames[0]].getGlyphOrder()
def setGlyphOrder(self, glyphOrder):
diff --git a/Lib/fontTools/ttLib/tables/C_O_L_R_.py b/Lib/fontTools/ttLib/tables/C_O_L_R_.py
index 31ef729..0fdf133 100644
--- a/Lib/fontTools/ttLib/tables/C_O_L_R_.py
+++ b/Lib/fontTools/ttLib/tables/C_O_L_R_.py
@@ -54,7 +54,7 @@
def compile(self, ttFont):
ordered = []
- ttFont.getReverseGlyphMap(rebuild=1)
+ ttFont.getReverseGlyphMap(rebuild=True)
glyphNames = self.ColorLayers.keys()
for glyphName in glyphNames:
try:
diff --git a/Lib/fontTools/ttLib/tables/V_O_R_G_.py b/Lib/fontTools/ttLib/tables/V_O_R_G_.py
index 5f29eb1..143b971 100644
--- a/Lib/fontTools/ttLib/tables/V_O_R_G_.py
+++ b/Lib/fontTools/ttLib/tables/V_O_R_G_.py
@@ -46,7 +46,7 @@
try:
gids = map(operator.getitem, [nameMap]*lenRecords, names)
except KeyError:
- nameMap = ttFont.getReverseGlyphMap(rebuild=1)
+ nameMap = ttFont.getReverseGlyphMap(rebuild=True)
gids = map(operator.getitem, [nameMap]*lenRecords, names)
vOriginTable = list(zip(gids, vorgs))
self.numVertOriginYMetrics = lenRecords
diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
index 674a1fc..61863e7 100644
--- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py
+++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py
@@ -387,7 +387,7 @@
try:
gids = list(map(operator.getitem, [nameMap]*lenCharCodes, names))
except KeyError:
- nameMap = ttFont.getReverseGlyphMap(rebuild=1)
+ nameMap = ttFont.getReverseGlyphMap(rebuild=True)
try:
gids = list(map(operator.getitem, [nameMap]*lenCharCodes, names))
except KeyError:
@@ -728,7 +728,7 @@
try:
gids = list(map(operator.getitem, [nameMap]*lenCharCodes, names))
except KeyError:
- nameMap = ttFont.getReverseGlyphMap(rebuild=1)
+ nameMap = ttFont.getReverseGlyphMap(rebuild=True)
try:
gids = list(map(operator.getitem, [nameMap]*lenCharCodes, names))
except KeyError:
@@ -954,7 +954,7 @@
try:
gids = list(map(operator.getitem, [nameMap]*lenCharCodes, names))
except KeyError:
- nameMap = ttFont.getReverseGlyphMap(rebuild=1)
+ nameMap = ttFont.getReverseGlyphMap(rebuild=True)
try:
gids = list(map(operator.getitem, [nameMap]*lenCharCodes, names))
except KeyError:
diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
index b3f5eaa..659d0bb 100644
--- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py
+++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py
@@ -214,7 +214,7 @@
return
self.data = data
- def compact(self, glyfTable, recalcBBoxes=1):
+ def compact(self, glyfTable, recalcBBoxes=True):
data = self.compile(glyfTable, recalcBBoxes)
self.__dict__.clear()
self.data = data
@@ -234,7 +234,7 @@
else:
self.decompileCoordinates(data)
- def compile(self, glyfTable, recalcBBoxes=1):
+ def compile(self, glyfTable, recalcBBoxes=True):
if hasattr(self, "data"):
return self.data
if self.numberOfContours == 0:
diff --git a/Lib/fontTools/ttLib/tables/otTables.py b/Lib/fontTools/ttLib/tables/otTables.py
index f4e8ac5..4ecaf0f 100644
--- a/Lib/fontTools/ttLib/tables/otTables.py
+++ b/Lib/fontTools/ttLib/tables/otTables.py
@@ -54,12 +54,12 @@
start = r.Start
end = r.End
try:
- startID = font.getGlyphID(start, requireReal=1)
+ startID = font.getGlyphID(start, requireReal=True)
except KeyError:
warnings.warn("Coverage table has start glyph ID out of range: %s." % start)
continue
try:
- endID = font.getGlyphID(end, requireReal=1)
+ endID = font.getGlyphID(end, requireReal=True)
except KeyError:
warnings.warn("Coverage table has end glyph ID out of range: %s." % end)
endID = len(glyphOrder)