From b34fba1020fc242198cbbdcc4339caaf622302b5 Mon Sep 17 00:00:00 2001 From: Sebastian Muszytowski Date: Wed, 13 Jan 2016 17:44:41 +0100 Subject: added font.h and converter --- font_to_json.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 font_to_json.py (limited to 'font_to_json.py') diff --git a/font_to_json.py b/font_to_json.py new file mode 100644 index 0000000..6d1b667 --- /dev/null +++ b/font_to_json.py @@ -0,0 +1,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) -- cgit v1.2.3