summaryrefslogtreecommitdiff
path: root/utilities/font_to_json.py
blob: 6d1b66712289c7dc10f766c81187792f8e926f74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/python

import sys
import os
import re
import json

result = {}

with open('font.h') as font:
	for line in font:
		if 'PROGMEM' in line:
			hexes = re.findall(r'(0x[0-9a-fA-F]+)',line)
			contents = hexes[1:]
			length = len(contents)
			literal = int(re.findall(r'chr_([0-9]+)',line)[0])
			description = re.findall(r'\/\/(.*)$',line)[0].strip()
			#for row in contents:
			#	print '{0:08b}'.format(int(row,16)) #.replace("1",u"\u2588").replace("0",u"\u25A2")
			result[str(literal)] = {
				'literal' : literal,
				'description' : description,
				'hexcolumns' : contents,
				'length' : length
			}

print json.dumps(result)