summaryrefslogtreecommitdiff
path: root/scripts/lib/fontbuild/kerning.py
diff options
context:
space:
mode:
authorJames Godfrey-Kittle <jamesgk@google.com>2015-04-22 17:47:22 -0700
committerjamesgk <jamesgk19@gmail.com>2015-04-22 17:47:22 -0700
commitb224649b21c4965ddc22b00a50bfe5ff9449e1fc (patch)
tree4d3e7350f33252fbb0eb9a7f8e7018a2d532e7b9 /scripts/lib/fontbuild/kerning.py
parentaf4e18491e9e1e3013034d0ae5510c188df7ae0c (diff)
Clean up kern feature generation a bit.
Diffstat (limited to 'scripts/lib/fontbuild/kerning.py')
-rw-r--r--scripts/lib/fontbuild/kerning.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/scripts/lib/fontbuild/kerning.py b/scripts/lib/fontbuild/kerning.py
index abb61f3..01aac2a 100644
--- a/scripts/lib/fontbuild/kerning.py
+++ b/scripts/lib/fontbuild/kerning.py
@@ -43,21 +43,22 @@ class KernFeatureWriter(AbstractFeatureWriter):
for rightName, rightContents in self.rightClasses:
rightKey = rightContents[0]
pair = leftKey, rightKey
- if not self.kerning.has_key(pair):
+ val = self.kerning[pair]
+ if val is None:
continue
- classPairKerning[leftName, rightName] = self.kerning[pair]
+ classPairKerning[leftName, rightName] = val
self.kerning.remove(pair)
# collect rules with left class and right glyph
for pair, val in self.kerning.getLeft(leftKey):
- leftClassKerning[leftName, pair[1]] = self.kerning[pair]
+ leftClassKerning[leftName, pair[1]] = val
self.kerning.remove(pair)
# collect rules with left glyph and right class
for rightName, rightContents in self.rightClasses:
rightKey = rightContents[0]
for pair, val in self.kerning.getRight(rightKey):
- rightClassKerning[pair[0], rightName] = self.kerning[pair]
+ rightClassKerning[pair[0], rightName] = val
self.kerning.remove(pair)
# write the feature
@@ -78,9 +79,11 @@ class KernFeatureWriter(AbstractFeatureWriter):
pairs = kerning.items()
pairs.sort()
for (left, right), val in pairs:
- rulesAdded = (
- self.classSizes.get(left, 1) * self.classSizes.get(right, 1)
- if enum else 1)
+ if enum:
+ rulesAdded = (self.classSizes.get(left, 1) *
+ self.classSizes.get(right, 1))
+ else:
+ rulesAdded = 1
self.ruleCount += rulesAdded
if self.ruleCount > 2048:
lines.append(" subtable;")