Overview
| Artifact ID: | 427b58ccbf79808aadcceca131edaccd4c30260c |
|---|---|
| Ticket: | 968725ffffffffffffffffffffffffffffffffff |
| Date: | 2004-06-08 15:46:56 |
| User: | mdejong |
| Artifact Attached: | 53a6fb0cbc3b312512b9cc1c7f4cf16bbb30d275 |
| Filename: | canvas_text_alias_bug.txt |
| Description: | Tcl source code that shows the problem |
Content:
# Example script to show anti-aliasing bug in canvas
# text object. This problem only seems to show up
# when rendering selected text in the canvas.
set fg red
set bg black
set sel yellow
set font {Arial 33}
set str {Hello$Ther@$pal}
set hrange {6 10}
if {0} {
set str {Hello}
set hrange {0 4}
}
if {0} {
set str {Well Hello}
set hrange {5 9}
}
destroy .t .c
set t [text .t \
-width 30 -height 1 \
-font $font \
-bg $bg \
-fg $fg
]
set c [canvas .c \
-width [winfo reqwidth $t] -height [winfo reqheight $t] \
-bg $bg \
-borderwidth 0 \
-highlightthickness 0 \
-selectforeground $sel \
-selectbackground $bg \
-selectborderwidth 0
]
grid $t -row 0 -column 0 -sticky news
grid $c -row 1 -column 0 -sticky news
$t delete 1.0 end
$t insert end $str
$c delete all
$c create text 4 3 \
-text $str \
-font $font \
-fill $fg \
-anchor nw \
-tags {ttag}
# Highlight text widget
$t tag configure highlight -foreground $sel
$t tag add highlight 1.[lindex $hrange 0] [list 1.[lindex $hrange 1] + 1 char]
# Highlight canvas widget
$c select clear
$c select from ttag [lindex $hrange 0]
$c select to ttag [lindex $hrange 1]
