Updates to allow passing in prefix and outputing the count of glyphs

This commit is contained in:
Ryan L McIntyre 2018-02-14 21:28:26 -05:00
parent b119fb4525
commit 780abd4432

View file

@ -37,6 +37,7 @@ parser = argparse.ArgumentParser(description='Nerd Fonts Glyph Info Generator: d
parser.add_argument('-start', '--start', type=str, nargs='?', dest='symbolFontStart', help='The starting unicode hex codepoint')
parser.add_argument('-end', '--end', type=str, nargs='?', dest='symbolFontEnd', help='The ending unicode hex codepoint')
parser.add_argument('-offset', '--offset', type=str, nargs='?', dest='symbolOffset', help='The amount (in hex) to offset the range by for the source font')
parser.add_argument('-prefix', '--prefix', type=str, nargs='?', dest='prefix', help='The prefix to use for the shell variables and css names')
parser.add_argument('-font', '--font', type=str, nargs='?', dest='filepath', help='The file path to the font file to open')
args = parser.parse_args()
@ -47,16 +48,18 @@ symbolFont = fontforge.open(args.filepath)
args.symbolFontStart = int("0x" + args.symbolFontStart, 16)
args.symbolFontEnd = int("0x" + args.symbolFontEnd, 16)
args.symbolOffset = int("0x" + args.symbolOffset, 16)
ctr = 0
symbolFont.selection.select((str("ranges"),str("unicode")),args.symbolFontStart,args.symbolFontEnd)
for index, sym_glyph in enumerate(symbolFont.selection.byGlyphs):
slot = format(sym_glyph.unicode, 'X')
name = sym_glyph.glyphname
sh_name = "i_mdi_" + name.replace("-", "_")
sh_name = "i_" + args.prefix + "_" + name.replace("-", "_")
char = unichr(int('0x'+slot, 16) + int('0x'+format(args.symbolOffset, 'X'), 16))
print("i='" + char + "' " + sh_name + "=$i")
ctr += 1
print("DONE")
print("Done, generated " + str(ctr) + " glyphs")