', type=str, nargs='*',
help='Only generate specific glyphs.')
args = argparser.parse_args()
srcDir = os.path.join(BASEDIR, 'src')
deleteNames = set(['.notdef', '.null'])
if len(args.scale):
scale = float(args.scale)
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(),
RemoveOverlapsFilter(backend=RemoveOverlapsFilter.Backend.SKIA_PATHOPS),
]
glyphSet = {g.name: g for g in ufo}
for func in filters:
func(ufo, glyphSet)
print('generating SVGs and metrics data')
# print('\n'.join(ufo.keys()))
# sys.exit(0)
glyphMetrics = {}
# jsonLines = []
svgLines = []
for glyphname in glyphnames:
generateFrom = None
svg, metrics = genGlyph(glyphname)
# metrics: (width, advance, left, right)
glyphMetrics[nameToIdMap[glyphname]] = metrics
svgLines.append(svg.replace('\n', ''))
# print('{\n' + ',\n'.join(jsonLines) + '\n}')
svgtext = '\n'.join(svgLines)
# print(svgtext)
glyphsHtmlFilename = os.path.join(BASEDIR, 'docs', 'glyphs', 'index.html')
html = u''
with open(glyphsHtmlFilename, 'r', encoding="utf-8") as f:
html = f.read()
startMarker = u''
startPos = html.find(startMarker)
endMarker = u'