summaryrefslogtreecommitdiff
path: root/misc/tools
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@figma.com>2019-05-27 03:08:05 +0300
committerRasmus Andersson <rasmus@figma.com>2019-05-27 03:08:05 +0300
commit850e4df74b006d481d5b81b31a47a9bf39204980 (patch)
tree8364dc2addaadfb27167c3dbd44392816c9fb092 /misc/tools
parente3af7653ac4a94a13dea672ba412eabd4cb1be93 (diff)
downloadinter-850e4df74b006d481d5b81b31a47a9bf39204980.tar.xz
tooling: fixes a bug in gen-metrics-and-svgs.py where the very first glyph would not get recognized in the kerning lookup table, causing no kerning information to appear on the website
Diffstat (limited to 'misc/tools')
-rwxr-xr-xmisc/tools/gen-metrics-and-svgs.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/misc/tools/gen-metrics-and-svgs.py b/misc/tools/gen-metrics-and-svgs.py
index 34d5d3458..4b6ff22a2 100755
--- a/misc/tools/gen-metrics-and-svgs.py
+++ b/misc/tools/gen-metrics-and-svgs.py
@@ -191,7 +191,7 @@ def genKerningInfo(ufo, glyphnames, nameToIdMap):
for rname in rightnames:
lnameId = nameToIdMap.get(lname)
rnameId = nameToIdMap.get(rname)
- if lnameId and rnameId:
+ if lnameId is not None and rnameId is not None:
pairs.append([lnameId, rnameId, v])
# print('pairs: %r' % pairs)
@@ -247,6 +247,22 @@ ufopath = args.ufopath.rstrip('/')
ufo = Font(ufopath)
effectiveAscender = max(ufo.info.ascender, ufo.info.unitsPerEm)
+
+deleteNames.add('.notdef')
+deleteNames.add('.null')
+
+glyphnames = args.glyphs if len(args.glyphs) else ufo.keys()
+glyphnameSet = set(glyphnames)
+
+glyphnames = [gn for gn in glyphnames if gn not in deleteNames]
+glyphnames.sort()
+
+nameToIdMap, idToNameMap = genGlyphIDs(glyphnames)
+
+print('generating kerning pair data')
+kerning = genKerningInfo(ufo, glyphnames, nameToIdMap)
+
+
print('preprocessing glyphs')
filters = [
DecomposeComponentsFilter(),
@@ -261,16 +277,6 @@ print('generating SVGs and metrics data')
# print('\n'.join(ufo.keys()))
# sys.exit(0)
-deleteNames.add('.notdef')
-deleteNames.add('.null')
-
-glyphnames = args.glyphs if len(args.glyphs) else ufo.keys()
-glyphnameSet = set(glyphnames)
-
-glyphnames = [gn for gn in glyphnames if gn not in deleteNames]
-glyphnames.sort()
-
-nameToIdMap, idToNameMap = genGlyphIDs(glyphnames)
glyphMetrics = {}
@@ -307,7 +313,6 @@ if startPos == -1 or endPos == -1:
print(msg % relfilename, file=sys.stderr)
sys.exit(1)
-kerning = genKerningInfo(ufo, glyphnames, nameToIdMap)
metaJson = '{\n'
metaJson += '"nameids":' + fmtJsonDict(idToNameMap) + ',\n'
metaJson += '"metrics":' + fmtJsonDict(glyphMetrics) + ',\n'