6 from math import acos, pi
9 print("Usage: %s handwriting-ja.xml" % sys.argv[0])
13 def __init__(self, s):
15 self.x = int(int(s[0]))
16 self.y = int(int(s[1]))
17 def __eq__(self, other):
18 return self.x == other.x and self.y == other.y
20 def get_chr(pts, cap = False):
26 if p0 == p1: return ""
36 if 5*pi/8 < a and a < 7*pi/8:
38 elif 3*pi/8 <= a and a <= 5*pi/8:
40 elif pi/8 < a and a < 3*pi/8:
43 if 5*pi/8 < a and a < 7*pi/8:
45 elif 3*pi/8 <= a and a <= 5*pi/8:
47 elif pi/8 < a and a < 3*pi/8:
54 fo = open("tomoe.utf16", 'wb')
55 fo.write(codecs.BOM_UTF16_LE)
67 for i in f.readlines():
68 if i.find("utf8") != -1:
72 i = i.replace("utf8", "")
73 i = i.strip(" ><x&#;/\n\r")
74 if len(i) != 4: continue
76 #fo.write(bytes.fromhex(j))
79 if i.find("<point") != -1:
80 i = i.replace("point", "")
81 i = i.replace("=", "")
82 i = i.replace("x", "")
83 i = i.replace("y", "")
84 i = i.replace("\"", "")
85 i = i.lstrip(" ><x&#;/\n\r")
86 i = i.rstrip(" ><x&#;/\n\r")
91 strokes += get_chr(pts, cap)
94 if i.find("<stroke>") != -1:
97 if i.find("</stroke>") != -1:
100 if i.find("</strokes>") != -1:
102 for j in range(0, len(strokes)):
103 if str.isupper(strokes[j]): l += 1
105 if l > ord('Z'): l = ord('Z')
106 fo.write(bytes.fromhex("%.2X00" % l))
108 for j in range(0, len(strokes)):
109 fo.write(bytes.fromhex("%.2X00" % ord(strokes[j])))
110 fo.write(bytes.fromhex("0A00"))