summaryrefslogtreecommitdiffstats
path: root/tests/font.test
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2024-01-27 13:49:12 (GMT)
committerfvogel <fvogelnew1@free.fr>2024-01-27 13:49:12 (GMT)
commit2333c3419bc229caab17d889c3919d31a4f2f497 (patch)
tree4981d0044613c647a97217e19fa0eaca5c09b508 /tests/font.test
parent52ee352e4469c63b56322643d38caafc70025395 (diff)
parent39d0e46160c3d7562f25775ac8c645216333134e (diff)
downloadtk-2333c3419bc229caab17d889c3919d31a4f2f497.zip
tk-2333c3419bc229caab17d889c3919d31a4f2f497.tar.gz
tk-2333c3419bc229caab17d889c3919d31a4f2f497.tar.bz2
Fix [8da7af2f8e]: slow widget creation if default font is not used.
Diffstat (limited to 'tests/font.test')
-rw-r--r--tests/font.test50
1 files changed, 29 insertions, 21 deletions
diff --git a/tests/font.test b/tests/font.test
index 9bf6d65..8794b98 100644
--- a/tests/font.test
+++ b/tests/font.test
@@ -596,12 +596,13 @@ test font-15.1 {Tk_AllocFontFromObj - converting internal reps} -constraints {
} -setup {
destroy .b1 .b2
} -body {
- set x {Times 16}
+ set x [font create font-15.1_font -family Times -size 16]
lindex $x 0
button .b1 -font $x
lindex $x 0
- testfont counts {Times 16}
+ testfont counts $x
} -cleanup {
+ font delete font-15.1_font
destroy .b1 .b2
} -result {{1 0}}
test font-15.2 {Tk_AllocFontFromObj - discard stale font} -constraints {
@@ -610,13 +611,14 @@ test font-15.2 {Tk_AllocFontFromObj - discard stale font} -constraints {
destroy .b1 .b2
set result {}
} -body {
- set x {Times 16}
+ set x [font create font-15.2_font -family Times -size 16]
button .b1 -font $x
destroy .b1
- lappend result [testfont counts {Times 16}]
+ lappend result [testfont counts $x]
button .b2 -font $x
- lappend result [testfont counts {Times 16}]
+ lappend result [testfont counts $x]
} -cleanup {
+ font delete font-15.2_font
destroy .b2
} -result {{} {{1 1}}}
test font-15.3 {Tk_AllocFontFromObj - reuse existing font} -constraints {
@@ -625,13 +627,14 @@ test font-15.3 {Tk_AllocFontFromObj - reuse existing font} -constraints {
destroy .b1 .b2
set result {}
} -body {
- set x {Times 16}
+ set x [font create font-15.3_font -family Times -size 16]
button .b1 -font $x
- lappend result [testfont counts {Times 16}]
+ lappend result [testfont counts $x]
button .b2 -font $x
pack .b1 .b2 -side top
- lappend result [testfont counts {Times 16}]
+ lappend result [testfont counts $x]
} -cleanup {
+ font delete font-15.3_font
destroy .b1 .b2
} -result {{{1 1}} {{2 1}}}
test font-15.4 {Tk_AllocFontFromObj procedure: bump ref count} -setup {
@@ -747,22 +750,24 @@ test font-16.1 {Tk_NameOfFont procedure} -setup {
test font-17.1 {Tk_FreeFontFromObj - reference counts} -constraints {
- testfont
+ testfont
} -setup {
destroy .b1 .b2 .b3
set result {}
} -body {
- set x {Courier 12}
+ set x [font create font-17.1_font -family Courier -size 12]
button .b1 -font $x
button .b3 -font $x
button .b2 -font $x
- lappend result [testfont counts {Courier 12}]
+ lappend result [testfont counts $x]
destroy .b1
- lappend result [testfont counts {Courier 12}]
+ lappend result [testfont counts $x]
destroy .b2
- lappend result [testfont counts {Courier 12}]
+ lappend result [testfont counts $x]
destroy .b3
- lappend result [testfont counts {Courier 12}]
+ lappend result [testfont counts $x]
+} -cleanup {
+ font delete font-17.1_font
} -result {{{3 1}} {{2 1}} {{1 1}} {}}
test font-17.2 {Tk_FreeFont procedure: one ref} -setup {
destroy .t.f
@@ -834,21 +839,24 @@ test font-18.1 {FreeFontObjProc} -constraints testfont -setup {
destroy .b1
set result {}
} -body {
- set x [join {Courier 12} { }]
+ set f [font create font-18.1_font -family Courier -size 12]
+ set x [join [list $f 50] { }]
button .b1 -font $x
- set y [join {Courier 12} { }]
+ set y [join [list $f 50] { }]
.b1 configure -font $y
- set z [join {Courier 12} { }]
+ set z [join [list $f 50] { }]
.b1 configure -font $z
- lappend result [testfont counts {Courier 12}]
+ lappend result [testfont counts [list $f 50]]
set x red
- lappend result [testfont counts {Courier 12}]
+ lappend result [testfont counts [list $f 50]]
set z 32
- lappend result [testfont counts {Courier 12}]
+ lappend result [testfont counts [list $f 50]]
destroy .b1
- lappend result [testfont counts {Courier 12}]
+ lappend result [testfont counts [list $f 50]]
set y bogus
return $result
+} -cleanup {
+ font delete font-18.1_font
} -result {{{1 3}} {{1 2}} {{1 1}} {}}