2 import sys
,string
,re
,os
4 def get_code(code
, font
):
16 ignore_list
= ["not", "braceld", "bracerd", "bracelu", "braceru",
17 "lmoustache", "rmoustache", "lgroup", "rgroup", "bracevert"]
21 lines
= fh
.readlines()
29 next_line
= lines
[i
+1]
31 # some entries are spread over two lines so we join the next line
32 # to the current one, (if current line contains a comment, we remove it)
33 line
= string
.split(line
,'%')[0]+next_line
35 mo
= re
.match(r
'.*\\DeclareSymbolFont\s*\{(.*?)\}\s*\{(.*?)\}\s*\{(.*?)\}.*', line
)
37 font_names
[mo
.group(1)] = mo
.group(3)
39 mo
= re
.match(r
'.*\\DeclareMath(Symbol|Delimiter)\s*\{?\\(\w*?)\}?\s*\{?\\(.*?)\}?\s*\{(.*?)\}\s*\{"(.*?)\}.*', line
)
46 mo
= re
.match(r
'.*\\edef\\(\w*?)\{.*?\{\\hexnumber@\\sym(.*?)\}(.*?)\}', line
)
53 if mo
!= None and symbol
not in ignore_list
:
54 mo2
= re
.match(r
'\s*\\def\\(.*?)\{', next_line
)
55 if mo2
!= None and symbol
== mo2
.group(1)+"op":
56 sys
.stderr
.write("%s -> %s\n" % (symbol
, mo2
.group(1)))
59 if font_names
.has_key(font
):
60 font
= font_names
[font
]
62 code
= get_code(string
.atoi(code
, 16), font
)
67 if xsymbols
.has_key(symbol
):
68 xcode
= xsymbols
[symbol
]
71 if symbols
.has_key(symbol
):
72 sys
.stderr
.write(symbol
+ " exists\n")
73 if code
!= symbols
[symbol
]:
74 sys
.stderr
.write("code is not equal!!!\n")
76 symbols
[symbol
] = code
77 print "%-18s %-4s %3d %3d %-6s" % (symbol
,font
,code
,xcode
,type)
80 path
= os
.path
.split(sys
.argv
[0])[0]
81 fh
= open(os
.path
.join(path
, "x-font"))
82 lines
= fh
.readlines()
85 x
= string
.split(line
)
87 code
= string
.atoi(x
[1],16)
88 xsymbols
[symbol
] = code
90 for file in sys
.argv
[1:]:
91 print "# Generated from " + os
.path
.basename(file) + "\n"
96 ("neq", "x", 0, 185, "mathrel"),
97 ("textdegree", "x", 0, 176, "mathord"),
98 ("cong", "x", 0, 64, "mathrel"),
99 ("surd", "x", 0, 214, "mathord")
102 if xsymbols
.has_key("leq"):
106 print "%-18s %-4s %3d %3d %-6s" % x
107 if xsymbols
.has_key(x
[0]):
111 lyxbar cmsy 161 0 mathord
112 lyxeq cmr 61 0 mathord
113 lyxdabar msa 57 0 mathord
114 lyxright msa 75 0 mathord
115 lyxleft msa 76 0 mathord
118 for symbol
in xsymbols
.keys():
119 sys
.stderr
.write(symbol
+"\n")