', type=str, nargs='*',
help='Only generate specific glyphs.')
args = argparser.parse_args()
srcDir = os.path.join(BASEDIR, 'src')
# load fontbuild config
config = RawConfigParser(dict_type=OrderedDict)
configFilename = os.path.join(srcDir, 'fontbuild.cfg')
config.read(configFilename)
deleteNames = set()
for sectionName, value in config.items('glyphs'):
if sectionName == 'delete':
deleteNames = set(value.split())
if len(args.scale):
scale = float(args.scale)
ufopath = args.ufopath.rstrip('/')
font = OpenFont(ufopath)
effectiveAscender = max(font.info.ascender, font.info.unitsPerEm)
# print('\n'.join(font.keys()))
# sys.exit(0)
agl = loadAGL(os.path.join(srcDir, 'glyphlist.txt')) # { 2126: 'Omega', ... }
deleteNames.add('.notdef')
deleteNames.add('.null')
glyphnames = args.glyphs if len(args.glyphs) else font.keys()
glyphnameSet = set(glyphnames)
generatedGlyphNames = set()
diacriticComps = loadGlyphCompositions(os.path.join(srcDir, '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 deleteNames]
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(BASEDIR, 'docs', 'glyphs', 'index.html')
html = ''
with open(glyphsHtmlFilename, 'r') as f:
html = f.read()
startMarker = ''
startPos = html.find(startMarker)
endMarker = '