2 import sys,string,re,os
7 def get_code(code, font):
19 ignore_list = ["not", "braceld", "bracerd", "bracelu", "braceru",
20 "lmoustache", "rmoustache", "lgroup", "rgroup", "bracevert"]
24 lines = fh.readlines()
32 next_line = lines[i+1]
34 # some entries are spread over two lines so we join the next line
35 # to the current one, (if current line contains a comment, we remove it)
36 line = string.split(line,'%')[0]+next_line
38 mo = re.match(r'.*\\DeclareSymbolFont\s*\{(.*?)\}\s*\{(.*?)\}\s*\{(.*?)\}.*', line)
40 font_names[mo.group(1)] = mo.group(3)
42 mo = re.match(r'.*\\DeclareMath(Symbol|Delimiter)\s*\{?\\(\w*?)\}?\s*\{?\\(.*?)\}?\s*\{(.*?)\}\s*\{"(.*?)\}.*', line)
49 mo = re.match(r'.*\\edef\\(\w*?)\{.*?\{\\hexnumber@\\sym(.*?)\}(.*?)\}', line)
56 if mo != None and symbol not in ignore_list:
57 mo2 = re.match(r'\s*\\def\\(.*?)\{', next_line)
58 if mo2 != None and is_prefix(symbol,mo2.group(1)):
59 sys.stderr.write("%s -> %s\n" % (symbol, mo2.group(1)))
62 if font_names.has_key(font):
63 font = font_names[font]
65 code = get_code(string.atoi(code, 16), font)
70 if xsymbols.has_key(symbol):
71 xcode = xsymbols[symbol]
74 if symbols.has_key(symbol):
75 sys.stderr.write(symbol+ " exists\n")
76 if code != symbols[symbol]:
77 sys.stderr.write("code is not equal!!!\n")
79 symbols[symbol] = code
80 print "%-18s %-4s %3d %3d %-6s" % (symbol,font,code,xcode,type)
83 path = os.path.split(sys.argv[0])[0]
84 fh = open(os.path.join(path, "x-font"))
85 lines = fh.readlines()
88 x = string.split(line)
90 code = string.atoi(x[1],16)
91 xsymbols[symbol] = code
93 for file in sys.argv[1:]:
94 print "# Generated from " + os.path.basename(file) + "\n"
99 ("neq", "none", 0, 185, "mathrel"),
100 ("textdegree", "none", 0, 176, "mathord"),
101 ("cong", "none", 0, 64, "mathrel"),
102 ("surd", "note", 0, 214, "mathord")
105 if xsymbols.has_key("leq"):
109 print "%-18s %-4s %3d %3d %-6s" % x
110 if xsymbols.has_key(x[0]):
113 for symbol in xsymbols.keys():
114 sys.stderr.write(symbol+"\n")