3 # Script built on an idea of Jules Bean to extract "what TeX would do" from
6 # Call it with texify '\macro' [...] to get a line per item giving ascent,
7 # descent, width, the font and the position in the font TeX would use to
14 #\message{\string\meaning\temp}
15 #\setbox5=\box{$\entails$}
19 set filebase texifytmp
20 set hboxexp {^\\hbox.([0-9.]+)\+([0-9.]+).x([0-9.]+)}
21 set fontexp {^\.+\\ten([a-z]+) (.*)$}
23 foreach item $::argv {
31 set f [open $filebase.tex w 0600]
32 puts $f "\\nonstopmode"
33 puts $f "\\setbox5=\\hbox\{\$$item\$\}"
39 if {[catch {exec tex $filebase.tex} err]} {
43 set f [open $filebase.log r]
46 # try to interpret it as a hbox line
47 regexp $hboxexp $line dummy ascent descent width
48 # try to interpret it as a font line
49 regexp $fontexp $line dummy font char
53 if {![string equal $font "unknown"]} {
54 if {[string equal -length 2 $char {^^}]} {
55 scan $char "%c%c%c" dummy1 dummy2 value
56 set value [expr {$value - 64}]
62 puts [list $ascent $descent $width $font $value $char]