From 780abd44322e60f66077c5b0fccfff5c55bfadf0 Mon Sep 17 00:00:00 2001 From: Ryan L McIntyre Date: Wed, 14 Feb 2018 21:28:26 -0500 Subject: [PATCH] Updates to allow passing in prefix and outputing the count of glyphs --- bin/scripts/generate-glyph-info-from-set.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/scripts/generate-glyph-info-from-set.py b/bin/scripts/generate-glyph-info-from-set.py index 39d420696..5a60878f9 100755 --- a/bin/scripts/generate-glyph-info-from-set.py +++ b/bin/scripts/generate-glyph-info-from-set.py @@ -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")