summaryrefslogtreecommitdiffstats
path: root/contrib/python/fonttools/fontTools/ttLib/woff2.py
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-07-31 11:14:11 +0300
committerrobot-piglet <[email protected]>2025-07-31 12:10:37 +0300
commite177928be72df9669dbb830824b4233a33c8723f (patch)
treea91d4ec6bbe7dc221c049475a91255c2996fd84e /contrib/python/fonttools/fontTools/ttLib/woff2.py
parenta1700abf3c749b43117e757deb259d2a7bcdf46a (diff)
Intermediate changes
commit_hash:60aaacde4a6a0fb68b6435d7f100365d0c77d64d
Diffstat (limited to 'contrib/python/fonttools/fontTools/ttLib/woff2.py')
-rw-r--r--contrib/python/fonttools/fontTools/ttLib/woff2.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/contrib/python/fonttools/fontTools/ttLib/woff2.py b/contrib/python/fonttools/fontTools/ttLib/woff2.py
index 03667e834b7..c11aeb2e543 100644
--- a/contrib/python/fonttools/fontTools/ttLib/woff2.py
+++ b/contrib/python/fonttools/fontTools/ttLib/woff2.py
@@ -394,10 +394,9 @@ class WOFF2Writer(SFNTWriter):
def _calcMasterChecksum(self):
"""Calculate checkSumAdjustment."""
- tags = list(self.tables.keys())
checksums = []
- for i in range(len(tags)):
- checksums.append(self.tables[tags[i]].checkSum)
+ for tag in self.tables.keys():
+ checksums.append(self.tables[tag].checkSum)
# Create a SFNT directory for checksum calculation purposes
self.searchRange, self.entrySelector, self.rangeShift = getSearchRange(
@@ -642,10 +641,10 @@ woff2OverlapSimpleBitmapFlag = 0x0001
def getKnownTagIndex(tag):
"""Return index of 'tag' in woff2KnownTags list. Return 63 if not found."""
- for i in range(len(woff2KnownTags)):
- if tag == woff2KnownTags[i]:
- return i
- return woff2UnknownTagIndex
+ try:
+ return woff2KnownTags.index(tag)
+ except ValueError:
+ return woff2UnknownTagIndex
class WOFF2DirectoryEntry(DirectoryEntry):
@@ -747,8 +746,8 @@ class WOFF2LocaTable(getTableClass("loca")):
"indexFormat is 0 but local offsets not multiples of 2"
)
locations = array.array("H")
- for i in range(len(self.locations)):
- locations.append(self.locations[i] // 2)
+ for location in self.locations:
+ locations.append(location // 2)
else:
locations = array.array("I", self.locations)
if sys.byteorder != "big":
@@ -1026,11 +1025,10 @@ class WOFF2GlyfTable(getTableClass("glyf")):
lastcomponent = len(glyph.components) - 1
more = 1
haveInstructions = 0
- for i in range(len(glyph.components)):
+ for i, component in enumerate(glyph.components):
if i == lastcomponent:
haveInstructions = hasattr(glyph, "program")
more = 0
- component = glyph.components[i]
self.compositeStream += component.compile(more, haveInstructions, self)
if haveInstructions:
self._encodeInstructions(glyph)
@@ -1078,9 +1076,8 @@ class WOFF2GlyfTable(getTableClass("glyf")):
flags = array.array("B")
triplets = array.array("B")
- for i in range(len(coordinates)):
+ for i, (x, y) in enumerate(coordinates):
onCurve = glyph.flags[i] & _g_l_y_f.flagOnCurve
- x, y = coordinates[i]
absX = abs(x)
absY = abs(y)
onCurveBit = 0 if onCurve else 128