', type=str, nargs='*',
help='Only generate specific glyphs.')
args = argparser.parse_args()
if len(args.scale):
scale = float(args.scale)
ufopath = args.ufopath.rstrip('/')
font = OpenFont(ufopath)
effectiveAscender = max(font.info.ascender, font.info.unitsPerEm)
srcdir = os.path.abspath(os.path.join(__file__, '..', '..'))
# print('\n'.join(font.keys()))
# sys.exit(0)
agl = loadAGL(os.path.join(srcdir, 'src', 'glyphlist.txt')) # { 2126: 'Omega', ... }
ignoreGlyphs = set(['.notdef', '.null'])
glyphnames = args.glyphs if len(args.glyphs) else font.keys()
glyphnameSet = set(glyphnames)
generatedGlyphNames = set()
diacriticComps = loadGlyphCompositions(os.path.join(srcdir, 'src', 'diacritics.txt'))
for glyphName, comp in diacriticComps.iteritems():
if glyphName not in glyphnameSet:
generatedGlyphNames.add(glyphName)
glyphnames.append(glyphName)
glyphnameSet.add(glyphName)
glyphnames = [gn for gn in glyphnames if gn not in ignoreGlyphs]
glyphnames.sort()
nameToIdMap, idToNameMap = genGlyphIDs(glyphnames)
glyphMetrics = {}
# jsonLines = []
svgLines = []
for glyphname in glyphnames:
generateFrom = None
if glyphname in generatedGlyphNames:
generateFrom = diacriticComps[glyphname]
svg, metrics = genGlyph(glyphname, generateFrom, force=args.force)
# 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(srcdir, 'docs', 'glyphs', 'index.html')
html = ''
with open(glyphsHtmlFilename, 'r') as f:
html = f.read()
startMarker = ''
startPos = html.find(startMarker)
endMarker = '