#!/bin/sh
exec tclsh "$0" ${1+"$@"}
package require Gdtclft
set font times
set gd [gd create 1100 850]
set white [gd color new $gd 255 255 255]
set black [gd color new $gd 0 0 0]
set red [gd color new $gd 255 0 0]
set green [gd color new $gd 0 255 0]
proc incr_rowcol {} {
upvar 1 row row col col x1 x1 x2 x2 x3 x3 y y
if {! ($row % 40)} {
set x1 [expr $col * 120 + 10]
set x2 [expr $x1 + 30]
set x3 [expr $x1 + 60]
incr col
set y 10
}
incr row
incr y 20
}
gd text $gd $green $font 50. .7 350 500 "HTML 4.0 Entities\r\nfont = $font"
set row 0
set col 0
for {set val 32} {$val < 127} {incr val} {
set entity($val) [format {%c} $val]
}
set f [open entities.html r]
while {! [eof $f]} {
set rec [gets $f]
if {[scan $rec {<!ENTITY %s CDATA "& set entity($val) $name
}
}
foreach val [lsort -integer [array names entity]] {
incr_rowcol
if {$entity($val) == "hearts" || $entity($val) == "diams"} {
set fontcolor $red
} {
set fontcolor $black
}
gd text $gd $black $font 8. 0. $x1 $y [format {%5d} $val]
gd text $gd $fontcolor $font 16. 0. $x2 $y [format {& gd text $gd $black $font 12. 0. $x3 $y $entity($val)
}
close $f
set f stdout
gd writePNG $gd $f