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
This commit is contained in:
parent
e3af7653ac
commit
850e4df74b
1 changed files with 17 additions and 12 deletions
|
|
@ -191,7 +191,7 @@ def genKerningInfo(ufo, glyphnames, nameToIdMap):
|
||||||
for rname in rightnames:
|
for rname in rightnames:
|
||||||
lnameId = nameToIdMap.get(lname)
|
lnameId = nameToIdMap.get(lname)
|
||||||
rnameId = nameToIdMap.get(rname)
|
rnameId = nameToIdMap.get(rname)
|
||||||
if lnameId and rnameId:
|
if lnameId is not None and rnameId is not None:
|
||||||
pairs.append([lnameId, rnameId, v])
|
pairs.append([lnameId, rnameId, v])
|
||||||
|
|
||||||
# print('pairs: %r' % pairs)
|
# print('pairs: %r' % pairs)
|
||||||
|
|
@ -247,6 +247,22 @@ ufopath = args.ufopath.rstrip('/')
|
||||||
ufo = Font(ufopath)
|
ufo = Font(ufopath)
|
||||||
effectiveAscender = max(ufo.info.ascender, ufo.info.unitsPerEm)
|
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')
|
print('preprocessing glyphs')
|
||||||
filters = [
|
filters = [
|
||||||
DecomposeComponentsFilter(),
|
DecomposeComponentsFilter(),
|
||||||
|
|
@ -261,16 +277,6 @@ print('generating SVGs and metrics data')
|
||||||
# print('\n'.join(ufo.keys()))
|
# print('\n'.join(ufo.keys()))
|
||||||
# sys.exit(0)
|
# 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 = {}
|
glyphMetrics = {}
|
||||||
|
|
||||||
|
|
@ -307,7 +313,6 @@ if startPos == -1 or endPos == -1:
|
||||||
print(msg % relfilename, file=sys.stderr)
|
print(msg % relfilename, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
kerning = genKerningInfo(ufo, glyphnames, nameToIdMap)
|
|
||||||
metaJson = '{\n'
|
metaJson = '{\n'
|
||||||
metaJson += '"nameids":' + fmtJsonDict(idToNameMap) + ',\n'
|
metaJson += '"nameids":' + fmtJsonDict(idToNameMap) + ',\n'
|
||||||
metaJson += '"metrics":' + fmtJsonDict(glyphMetrics) + ',\n'
|
metaJson += '"metrics":' + fmtJsonDict(glyphMetrics) + ',\n'
|
||||||
|
|
|
||||||
Reference in a new issue