mirror of
https://github.com/rsms/inter.git
synced 2024-11-23 11:43:47 +03:00
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
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user