Skip to content

Commit

Permalink
Updates patcher and source script for Weather glyph set (issue #247)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanoasis committed Mar 20, 2018
1 parent d4e4ef1 commit 042af27
Show file tree
Hide file tree
Showing 3 changed files with 246 additions and 236 deletions.
18 changes: 14 additions & 4 deletions bin/scripts/generate-glyph-info-from-set.py
@@ -1,10 +1,11 @@
#!/usr/bin/env python
# coding=utf8
# Nerd Fonts Version: 2.0.0
# Script Version: 1.0.0
# Script Version: 1.1.0

# Example Usage:
# ./generate-glyph-info-from-set.py --font ../../src/glyphs/materialdesignicons-webfont.ttf --start f001 --end f847 --offset 4ff
# ./generate-glyph-info-from-set.py --font ../../src/glyphs/materialdesignicons-webfont.ttf --start f001 --end f847 --offset 4ff --prefix mdi
# ./generate-glyph-info-from-set.py --font ../../src/glyphs/weathericons-regular-webfont.ttf --start f000 --end f0eb --negoffset d00 --prefix weather

from __future__ import absolute_import, print_function, unicode_literals

Expand Down Expand Up @@ -38,6 +39,7 @@
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('-negoffset', '--negoffset', type=str, nargs='?', dest='negSymbolOffset', help='The amount (in hex) to negative 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()
Expand All @@ -48,16 +50,24 @@

args.symbolFontStart = int("0x" + args.symbolFontStart, 16)
args.symbolFontEnd = int("0x" + args.symbolFontEnd, 16)
args.symbolOffset = int("0x" + args.symbolOffset, 16)
ctr = 0

if args.negSymbolOffset:
args.negSymbolOffset = int("0x" + args.negSymbolOffset, 16)
sign = '-'
offset = args.negSymbolOffset
elif args.symbolOffset:
args.symbolOffset = int("0x" + args.symbolOffset, 16)
sign = ''
offset = args.symbolOffset

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_" + args.prefix + "_" + name.replace("-", "_")
char = unichr(int('0x'+slot, 16) + int('0x'+format(args.symbolOffset, 'X'), 16))
char = unichr(int('0x'+slot, 16) + int(sign+'0x'+format(offset, 'X'), 16))

print("i='" + char + "' " + sh_name + "=$i")
ctr += 1
Expand Down

0 comments on commit 042af27

Please sign in to comment.