src/untp/dataparse.py
def parse_fntdata(_data, _config, _extra_data_receiver=None):
	"""
	info face="Haettenschweiler" size=60 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2
	common lineHeight=64 base=53 scaleW=256 scaleH=128 pages=1 packed=0
	page id=0 file="attack_num.png"
	chars count=12
	char id=52 x=2 y=2 width=33 height=51 xoffset=0 yoffset=5 xadvance=32 page=0 chnl=0 letter="4"
	char id=48 x=37 y=2 width=29 height=50 xoffset=1 yoffset=6 xadvance=29 page=0 chnl=0 letter="0"
	char id=53 x=68 y=2 width=29 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="5"
	char id=57 x=99 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="9"
	char id=54 x=129 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="6"
	char id=56 x=159 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="8"
	char id=51 x=189 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="3"
	char id=50 x=219 y=2 width=28 height=49 xoffset=1 yoffset=7 xadvance=28 page=0 chnl=0 letter="2"
	char id=55 x=2 y=55 width=30 height=48 xoffset=1 yoffset=8 xadvance=28 page=0 chnl=0 letter="7"
	char id=49 x=34 y=55 width=20 height=48 xoffset=1 yoffset=8 xadvance=20 page=0 chnl=0 letter="1"
	char id=45 x=56 y=55 width=18 height=12 xoffset=1 yoffset=36 xadvance=19 page=0 chnl=0 letter="-"
	char id=32 x=76 y=55 width=0 height=0 xoffset=11 yoffset=73 xadvance=16 page=0 chnl=0 letter="space"
	"""
	data = {}
	frame_data_list = []

	parse_common_info = parse("common lineHeight={line_height:d} base={base:d} scaleW={scale_w:d} scaleH={scale_h:d} pages={pages:d} packed={packed:d}", _data[1])
	parse_page_info = parse("page id={id:d} file=\"{file}\"", _data[2])
	parse_char_count = parse("chars count={count:d}", _data[3])
	raw_frames_data = {}
	for index in xrange(0, parse_char_count["count"]):
		parse_frame = parse("char id={id:d} x={x:d} y={y:d} width={width:d} height={height:d} xoffset={xoffset:d} yoffset={yoffset:d} xadvance={xadvance:d} page={page:d} chnl={chnl:d} letter=\"{letter}\"", _data[index + 4])

		frame_data = {}
		frame_data["name"]        = "{prefix}_{id}.png".format(prefix= _config["prefix"], id=parse_frame["id"], letter=parse_frame["letter"])
		frame_data["source_size"] = (parse_frame["width"], parse_frame["height"])
		frame_data["rotated"]     = False
		frame_data["src_rect"]    = (parse_frame["x"], parse_frame["y"], parse_frame["x"] + parse_frame["width"], parse_frame["y"] + parse_frame["height"])
		frame_data["offset"]      = (0, 0)

		if parse_frame["width"] <= 0 or  parse_frame["height"] <= 0:
			continue

		frame_data_list.append(frame_data)

		parse_frame_named_data = parse_frame.named.copy()
		parse_frame_named_data["texture"] = frame_data["name"]

		raw_frames_data[parse_frame["id"]] = parse_frame_named_data

	data["texture"] = parse_page_info["file"]
	data["frames"] = frame_data_list

	if _extra_data_receiver != None:
		_extra_data_receiver["common"] = parse_common_info.named
		_extra_data_receiver["frames"] = raw_frames_data

	return data
def parse_fntdata(_data, _config, _extra_data_receiver=None):
	"""
	info face="Haettenschweiler" size=60 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2
	common lineHeight=64 base=53 scaleW=256 scaleH=128 pages=1 packed=0
	page id=0 file="attack_num.png"
	chars count=12
	char id=52 x=2 y=2 width=33 height=51 xoffset=0 yoffset=5 xadvance=32 page=0 chnl=0 letter="4"
	char id=48 x=37 y=2 width=29 height=50 xoffset=1 yoffset=6 xadvance=29 page=0 chnl=0 letter="0"
	char id=53 x=68 y=2 width=29 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="5"
	char id=57 x=99 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="9"
	char id=54 x=129 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="6"
	char id=56 x=159 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="8"
	char id=51 x=189 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="3"
	char id=50 x=219 y=2 width=28 height=49 xoffset=1 yoffset=7 xadvance=28 page=0 chnl=0 letter="2"
	char id=55 x=2 y=55 width=30 height=48 xoffset=1 yoffset=8 xadvance=28 page=0 chnl=0 letter="7"
	char id=49 x=34 y=55 width=20 height=48 xoffset=1 yoffset=8 xadvance=20 page=0 chnl=0 letter="1"
	char id=45 x=56 y=55 width=18 height=12 xoffset=1 yoffset=36 xadvance=19 page=0 chnl=0 letter="-"
	char id=32 x=76 y=55 width=0 height=0 xoffset=11 yoffset=73 xadvance=16 page=0 chnl=0 letter="space"
	"""
	data = {}
	frame_data_list = []

	parse_common_info = parse("common lineHeight={line_height:d} base={base:d} scaleW={scale_w:d} scaleH={scale_h:d} pages={pages:d} packed={packed:d}", _data[1])
	parse_page_info = parse("page id={id:d} file=\"{file}\"", _data[2])
	parse_char_count = parse("chars count={count:d}", _data[3])
	raw_frames_data = {}
	for index in xrange(0, parse_char_count["count"]):
		parse_frame = parse("char id={id:d} x={x:d} y={y:d} width={width:d} height={height:d} xoffset={xoffset:d} yoffset={yoffset:d} xadvance={xadvance:d} page={page:d} chnl={chnl:d} letter=\"{letter}\"", _data[index + 4])

		frame_data = {}
		frame_data["name"]        = "{prefix}_{id}.png".format(prefix= _config["prefix"], id=parse_frame["id"], letter=parse_frame["letter"])
		frame_data["source_size"] = (parse_frame["width"], parse_frame["height"])
		frame_data["rotated"]     = False
		frame_data["src_rect"]    = (parse_frame["x"], parse_frame["y"], parse_frame["x"] + parse_frame["width"], parse_frame["y"] + parse_frame["height"])
		frame_data["offset"]      = (0, 0)

		if parse_frame["width"] <= 0 or  parse_frame["height"] <= 0:
			continue

		frame_data_list.append(frame_data)

		parse_frame_named_data = parse_frame.named.copy()
		parse_frame_named_data["texture"] = frame_data["name"]

		raw_frames_data[parse_frame["id"]] = parse_frame_named_data

	data["texture"] = parse_page_info["file"]
	data["frames"] = frame_data_list

	if _extra_data_receiver != None:
		_extra_data_receiver["common"] = parse_common_info.named
		_extra_data_receiver["frames"] = raw_frames_data

	return data
def parse_fntdata ( _data , _config , _extra_data_receiver = None ) : data = { } frame_data_list = [ ] parse_common_info = parse ( "common lineHeight={line_height:d} base={base:d} scaleW={scale_w:d} scaleH={scale_h:d} pages={pages:d} packed={packed:d}" , _data [ 1 ] ) parse_page_info = parse ( "page id={id:d} file=\"{file}\"" , _data [ 2 ] ) parse_char_count = parse ( "chars count={count:d}" , _data [ 3 ] ) raw_frames_data = { } for index in xrange ( 0 , parse_char_count [ "count" ] ) : parse_frame = parse ( "char id={id:d} x={x:d} y={y:d} width={width:d} height={height:d} xoffset={xoffset:d} yoffset={yoffset:d} xadvance={xadvance:d} page={page:d} chnl={chnl:d} letter=\"{letter}\"" , _data [ index + 4 ] ) frame_data = { } frame_data [ "name" ] = "{prefix}_{id}.png" . format ( prefix = _config [ "prefix" ] , id = parse_frame [ "id" ] , letter = parse_frame [ "letter" ] ) frame_data [ "source_size" ] = ( parse_frame [ "width" ] , parse_frame [ "height" ] ) frame_data [ "rotated" ] = False frame_data [ "src_rect" ] = ( parse_frame [ "x" ] , parse_frame [ "y" ] , parse_frame [ "x" ] + parse_frame [ "width" ] , parse_frame [ "y" ] + parse_frame [ "height" ] ) frame_data [ "offset" ] = ( 0 , 0 ) if parse_frame [ "width" ] <= 0 or parse_frame [ "height" ] <= 0 : continue frame_data_list . append ( frame_data ) parse_frame_named_data = parse_frame . named . copy ( ) parse_frame_named_data [ "texture" ] = frame_data [ "name" ] raw_frames_data [ parse_frame [ "id" ] ] = parse_frame_named_data data [ "texture" ] = parse_page_info [ "file" ] data [ "frames" ] = frame_data_list if _extra_data_receiver != None : _extra_data_receiver [ "common" ] = parse_common_info . named _extra_data_receiver [ "frames" ] = raw_frames_data return data
info face="Haettenschweiler" size=60 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2
	common lineHeight=64 base=53 scaleW=256 scaleH=128 pages=1 packed=0
	page id=0 file="attack_num.png"
	chars count=12
	char id=52 x=2 y=2 width=33 height=51 xoffset=0 yoffset=5 xadvance=32 page=0 chnl=0 letter="4"
	char id=48 x=37 y=2 width=29 height=50 xoffset=1 yoffset=6 xadvance=29 page=0 chnl=0 letter="0"
	char id=53 x=68 y=2 width=29 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="5"
	char id=57 x=99 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="9"
	char id=54 x=129 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="6"
	char id=56 x=159 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="8"
	char id=51 x=189 y=2 width=28 height=50 xoffset=1 yoffset=6 xadvance=28 page=0 chnl=0 letter="3"
	char id=50 x=219 y=2 width=28 height=49 xoffset=1 yoffset=7 xadvance=28 page=0 chnl=0 letter="2"
	char id=55 x=2 y=55 width=30 height=48 xoffset=1 yoffset=8 xadvance=28 page=0 chnl=0 letter="7"
	char id=49 x=34 y=55 width=20 height=48 xoffset=1 yoffset=8 xadvance=20 page=0 chnl=0 letter="1"
	char id=45 x=56 y=55 width=18 height=12 xoffset=1 yoffset=36 xadvance=19 page=0 chnl=0 letter="-"
	char id=32 x=76 y=55 width=0 height=0 xoffset=11 yoffset=73 xadvance=16 page=0 chnl=0 letter="space"
info face = Haettenschweiler size = 60 bold = 0 italic = 0 charset = unicode = 0 stretchH = 100 smooth = 1 aa = 1 padding = 0 0 0 0 spacing = 2 2 common lineHeight = 64 base = 53 scaleW = 256 scaleH = 128 pages = 1 packed = 0 page id = 0 file = attack_num . png chars count = 12 char id = 52 x = 2 y = 2 width = 33 height = 51 xoffset = 0 yoffset = 5 xadvance = 32 page = 0 chnl = 0 letter = 4 char id = 48 x = 37 y = 2 width = 29 height = 50 xoffset = 1 yoffset = 6 xadvance = 29 page = 0 chnl = 0 letter = 0 char id = 53 x = 68 y = 2 width = 29 height = 50 xoffset = 1 yoffset = 6 xadvance = 28 page = 0 chnl = 0 letter = 5 char id = 57 x = 99 y = 2 width = 28 height = 50 xoffset = 1 yoffset = 6 xadvance = 28 page = 0 chnl = 0 letter = 9 char id = 54 x = 129 y = 2 width = 28 height = 50 xoffset = 1 yoffset = 6 xadvance = 28 page = 0 chnl = 0 letter = 6 char id = 56 x = 159 y = 2 width = 28 height = 50 xoffset = 1 yoffset = 6 xadvance = 28 page = 0 chnl = 0 letter = 8 char id = 51 x = 189 y = 2 width = 28 height = 50 xoffset = 1 yoffset = 6 xadvance = 28 page = 0 chnl = 0 letter = 3 char id = 50 x = 219 y = 2 width = 28 height = 49 xoffset = 1 yoffset = 7 xadvance = 28 page = 0 chnl = 0 letter = 2 char id = 55 x = 2 y = 55 width = 30 height = 48 xoffset = 1 yoffset = 8 xadvance = 28 page = 0 chnl = 0 letter = 7 char id = 49 x = 34 y = 55 width = 20 height = 48 xoffset = 1 yoffset = 8 xadvance = 20 page = 0 chnl = 0 letter = 1 char id = 45 x = 56 y = 55 width = 18 height = 12 xoffset = 1 yoffset = 36 xadvance = 19 page = 0 chnl = 0 letter = - char id = 32 x = 76 y = 55 width = 0 height = 0 xoffset = 11 yoffset = 73 xadvance = 16 page = 0 chnl = 0 letter = space