Commit b5d243c9 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files sort and split fontello config.json file

parent 06ba9f49
Sort and split a fontello config.json file according to 'src'
python config.json
import json
import copy
import sys
def dump(j, out):
print " ==> %-50s %3d glyphs" % (out, len(j['glyphs']))
json.dump(j, open(out, 'w'), indent=2)
name = sys.argv[1]
basename = name.replace('.json', '')
j = json.load(open(name))
glyphs = j['glyphs']
srcs = set(icon['src'] for icon in glyphs)
family_code = [ 0xE900, 0xEA00, 0xEB00, 0xEC00 ]
family = 0
for src in srcs:
code = family_code[family]
family += 1
jj = copy.deepcopy(j)
jj['glyphs'] = []
for icon in glyphs:
if not icon['src'] == src:
code += 1
icon['code'] = code
dump(jj, '%s-%s.json' % (basename, src))
dump(j, '%s-sorted.json' % basename)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment