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 and the primitives that TeX would use to typeset the item
13 #\message{\string\meaning\temp}
14 #\setbox5=\box{$\entails$}
18 set filebase texifytmp
19 set hboxexp {^\\hbox.([0-9.]+)\+([0-9.]+).x([0-9.]+)}
20 set fontexp {^\.+\\ten([a-z]+) (.*)$}
22 foreach item $::argv {
30 set f [open $filebase.tex w 0600]
31 puts $f "\\nonstopmode"
32 puts $f "\\setbox5=\\hbox\{\$$item\$\}"
38 if {[catch {exec tex $filebase.tex} err]} {
42 set f [open $filebase.log r]
45 regexp $hboxexp $line dummy ascent descent width
46 regexp $fontexp $line dummy font char
50 if {![string equal $font "unknown"]} {
51 if {[string equal -length 2 $char {^^}]} {
52 scan $char "%c%c%c" dummy1 dummy2 value
53 set value [expr {$value - 64}]
59 puts [list $ascent $descent $width $font $value $char]