from __future__ import with_statement import struct import sys import re def convert(input, output): with open(input, "r") as in_file: with open(output, "w") as out_file: def build_dic(parts): dic = {} for part in parts: key, value = part.split('=') try: dic[key] = int(value) except: dic[key] = value return dic def get_entry(line): while line[-1] == "\r" or line[-1] == "\n": line = line[0:-1] parts = [] quote = 0 part = "" for c in line: if c == "\"": quote = 1-quote elif c == " " and not quote: if part: parts.append(part) part = "" else: part += c if part: parts.append(part) type = parts[0] dic = build_dic(parts[1:]) return type, dic def write_int16(val): out_file.write(struct.pack('= 2: print "converting..." filenames = sys.argv[1:] for filename in filenames: input = filename output = re.sub("fnt$", "tfnt", input) print "input: %s, output: %s" % (input, output) convert(input, output) print "done!" else: print "font converter! converts .fnt files to teeworlds .tfnt" print "usage: font_converter "