if { [file exists  i:/tcl-80/tk8.0/library/stexfont.tcl] } {
set tk_library i:/tcl-80/tk8.0/library
}
set w .colors
catch {destroy $w}
toplevel $w
wm title $w "Listbox Demonstration (colors)"
wm iconname $w "Listbox"

set color red
set msg "To see another font click on it.   Démonstration des Typos."
set c $w.c
canvas $c  -width 450
set color [$c cget -background]
set stext [$c create stext 10 10 -anchor nw -width 430 -background $color -fill black -gamma1 .9 -percent_for_black .7]


proc resetPixelMap { args } {
    global c stext
    set new "$c create stext 10 10 "
    foreach v  [$c itemconfig $stext]  {
	lappend new [lindex $v 0] [lindex $v 4]
    }

    eval lappend new $args
    $c delete $stext
    setaliasing
    set stext [eval $new]
}
    
    
    
	
# set stext [$c create stext 10 10 -anchor nw -width 430 -background $color -fill black -gamma1 1.2 -percent_for_black .7]
set rect [$c create rectangle 10 10 10 10]



pack $c -side top


# set pkfonts [glob  $tk_library/stexfont/*.pk]
set fonts ""
source $tk_library/stexfont/stexfont.tcl
foreach v  [array names TkStexFontMap] {
    if { ![regexp {[0-9][0-9][0-9]} $TkStexFontMap($v) ] } {
	append fonts " [lindex [split $v .] 0]"
    }
}
set fonts [lsort $fonts]
#foreach v $pkfonts {
#   set v [file tail $v]
#   append fonts " [lindex [split $v .] 0]"
# }

proc resetfont { args } {
  global fonts stext c msg w rect
  set face [selection get]
  if { [lsearch $fonts $face] >= 0 } { } else { set face [lindex $fonts 0] }
  # puts [concat "<face: $face [$w.scale get]>" $msg]
   $c itemconfig $stext -stext [concat "<face:$face [$w.scale get]>" $msg]
  eval $c coords $rect [$c bbox $stext]

}


frame $w.frame -borderwidth 10
pack $w.frame -side top -expand yes -fill y

scrollbar $w.frame.scroll -command "$w.frame.list yview"
listbox $w.frame.list -yscroll "$w.frame.scroll set" \
	-width 30 -height 6 -setgrid 1
pack $w.frame.list $w.frame.scroll -side left -fill y -expand 1

bind $w.frame.list <Double-1> {
    resetfont
}
eval $w.frame.list insert 0 $fonts
set fr $w.frame

scale $w.scale -from 5 -to 200 -command resetfont -length 10c -orient horizontal  -label PointSize 
scale $fr.scale1 -from .1 -to 3.0 -command {resetPixelMap -gamma1}    -label gamma1  -resolution .1
scale $fr.scale2 -from .1 -to 1.0 -command {resetPixelMap -percent_for_black }   -label percentForBlack  -resolution .05
pack $fr.scale1 $fr.scale2 -side left

$fr.scale1 set 1.7
$fr.scale2 set .75

pack $w.scale  -side bottom
$w.scale set 22





