lib/fontcustom/scripts/generate.py in fontcustom-0.0.2 vs lib/fontcustom/scripts/generate.py in fontcustom-0.1.0

- old
+ new

@@ -4,11 +4,13 @@ import md5 import json from subprocess import call parser = argparse.ArgumentParser(description='Convert a directory of svg and eps files into a unified font file.') -parser.add_argument('dir', metavar='directory', type=unicode, nargs='+', help='directory of vector files') +parser.add_argument('dir', metavar='directory', type=unicode, nargs=2, help='directory of vector files') +parser.add_argument('--name', metavar='fontname', type=unicode, nargs='?', default='fontcustom', help='reference name of the font (no spaces)') +parser.add_argument('--nohash', '-n', action='store_true', help='disable hash fingerprinting of font files') args = parser.parse_args() f = fontforge.font() f.encoding = 'UnicodeFull' @@ -37,14 +39,19 @@ # glyph.round() files.append(name) cp += 1 -hashStr = m.hexdigest() -fontfile = args.dir[1] + '/fontcustom-' + hashStr +if args.nohash: + fontfile = args.dir[1] + '/' + args.name +else: + hashStr = m.hexdigest() + fontfile = args.dir[1] + '/' + args.name + '-' + hashStr -f.fontname = 'fontcustom' +f.fontname = args.name +f.familyname = args.name +f.fullname = args.name f.generate(fontfile + '.ttf') f.generate(fontfile + '.svg') # Fix SVG header for webkit (from: https://github.com/fontello/font-builder/blob/master/bin/fontconvert.py) svgfile = open(fontfile + '.svg', 'r+') @@ -57,7 +64,5 @@ call([scriptPath + '/sfnt2woff', fontfile + '.ttf']) call(scriptPath + '/ttf2eot ' + fontfile + '.ttf > ' + fontfile + '.eot', shell=True) # Hint the TTF file call(scriptPath + '/ttfautohint -s -n ' + fontfile + '.ttf ' + fontfile + '-hinted.ttf && mv ' + fontfile + '-hinted.ttf ' + fontfile + '.ttf', shell=True) - -print json.dumps({'file': fontfile, 'names': files})