mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-16 18:03:49 +00:00
3c4e567d44
codespell -w -i 3 -S Makefile.in -L mathed,afe,tthe,ue,fro,uint,larg,alph,te,thes,alle,Claus,wit,nd,numer src/mathed/
64 lines
1.4 KiB
Tcl
Executable File
64 lines
1.4 KiB
Tcl
Executable File
#!/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,
|
|
# descent, width, the font and the position in the font TeX would use to
|
|
# typeset the symbol.
|
|
|
|
# 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 width 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
|
|
# try to interpret it as a hbox line
|
|
regexp $hboxexp $line dummy ascent descent width
|
|
# try to interpret it as a font line
|
|
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]
|
|
}
|