2001-08-24 10:03:29 +00:00
|
|
|
#!/usr/bin/tclsh
|
|
|
|
|
|
|
|
# Script built on an idea of Jules Bean to extract "what TeX would do" from
|
|
|
|
# a given macro.
|
|
|
|
#
|
|
|
|
# Call it with texify '\macro' [...] to get a line per item giving ascent,
|
2001-08-28 13:34:04 +00:00
|
|
|
# descent, width, the font and the position in the font TeX would use to
|
|
|
|
# typeset the symbol.
|
2001-08-24 10:03:29 +00:00
|
|
|
|
|
|
|
# Original script:
|
|
|
|
#\batchmode
|
|
|
|
#\def\entails{$1}
|
|
|
|
#\edef\temp{\entails}
|
|
|
|
#\message{\string\meaning\temp}
|
|
|
|
#\setbox5=\box{$\entails$}
|
|
|
|
#\showbox5
|
|
|
|
#\bye
|
|
|
|
|
|
|
|
set filebase texifytmp
|
|
|
|
set hboxexp {^\\hbox.([0-9.]+)\+([0-9.]+).x([0-9.]+)}
|
|
|
|
set fontexp {^\.+\\ten([a-z]+) (.*)$}
|
|
|
|
|
|
|
|
foreach item $::argv {
|
|
|
|
set font unknown
|
|
|
|
set char {}
|
|
|
|
set value 0
|
|
|
|
set ascent 0
|
|
|
|
set descent 0
|
|
|
|
set widht 0
|
|
|
|
|
|
|
|
set f [open $filebase.tex w 0600]
|
|
|
|
puts $f "\\nonstopmode"
|
|
|
|
puts $f "\\setbox5=\\hbox\{\$$item\$\}"
|
|
|
|
puts $f "\\showbox5"
|
|
|
|
puts $f ""
|
|
|
|
puts $f "\\end"
|
|
|
|
close $f
|
|
|
|
|
|
|
|
if {[catch {exec tex $filebase.tex} err]} {
|
|
|
|
#puts "Error: '$err'"
|
|
|
|
}
|
|
|
|
|
|
|
|
set f [open $filebase.log r]
|
|
|
|
while {![eof $f]} {
|
|
|
|
gets $f line
|
2001-08-28 13:34:04 +00:00
|
|
|
# try to interpret it as a hbox line
|
2001-08-24 10:03:29 +00:00
|
|
|
regexp $hboxexp $line dummy ascent descent width
|
2001-08-28 13:34:04 +00:00
|
|
|
# try to interpret it as a font line
|
2001-08-24 10:03:29 +00:00
|
|
|
regexp $fontexp $line dummy font char
|
|
|
|
}
|
|
|
|
close $f
|
|
|
|
|
|
|
|
if {![string equal $font "unknown"]} {
|
|
|
|
if {[string equal -length 2 $char {^^}]} {
|
|
|
|
scan $char "%c%c%c" dummy1 dummy2 value
|
|
|
|
set value [expr {$value - 64}]
|
|
|
|
} else {
|
|
|
|
scan $char "%c" value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
puts [list $ascent $descent $width $font $value $char]
|
|
|
|
}
|