Tk Source Code

Changes On Branch bug-c0dbdd3ff3
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bug-c0dbdd3ff3 Excluding Merge-Ins

This is equivalent to a diff from 48a1e406 to fad15f3f

2017-02-05
17:35
Fix [c0dbdd3ff3]: Tk Compatibility Fonts block access to system fonts check-in: 678fdae0 user: fvogel tags: trunk
2017-02-01
21:15
Remove old pack syntax from the scripts of the Tk test suite check-in: 16a8fb9b user: fvogel tags: trunk
2017-01-28
17:38
Make tests pass again after fixing [c0dbdd3ff3]: Tk Compatibility Fonts block access to system fonts Closed-Leaf check-in: fad15f3f user: fvogel tags: bug-c0dbdd3ff3
17:37
Fixed [c0dbdd3ff3]: Tk Compatibility Fonts block access to system fonts check-in: 3f19aebf user: fvogel tags: bug-c0dbdd3ff3
2017-01-26
13:23
merge trunk check-in: 93e85a4b user: jan.nijtmans tags: novem-support
2017-01-25
22:10
Fix [140ea8ab38]: Long text lines are not drawn on Windows. check-in: 48a1e406 user: pspjuth tags: trunk
22:08
Fix [140ea8ab38]: Long text lines are not drawn on Windows. check-in: 8912c3c5 user: pspjuth tags: core-8-6-branch
2017-01-23
20:13
Fix [89a638af38]: OS X - textDisp-15.8 fails check-in: b0ed344f user: fvogel tags: trunk

Changes to tests/entry.test.

2301
2302
2303
2304
2305
2306
2307









2308
2309
2310

2311
2312
2313
2314
2315
2316
2317
2318
    entry .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
    pack .e
    focus .e
} -body {
    .e insert 0 "xyzzy"
    update
    .e delete 2 4









    winfo reqwidth .e
} -cleanup {
    destroy .e

} -result {31}

test entry-9.1 {EntryValueChanged procedure} -setup {
    unset -nocomplain x
} -body {
    trace variable x w override
    entry .e -textvariable x -width 0
    .e insert 0 foo







>
>
>
>
>
>
>
>
>
|


>
|







2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
    entry .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
    pack .e
    focus .e
} -body {
    .e insert 0 "xyzzy"
    update
    .e delete 2 4
    # To check that deletion actually happened we measure the new width
    # of the widget, based on the measuring width of the remaining text ("xyy")
    # in the widget. For that purpose we have to mirror the code in tkEntry.c
    # for computation of the reqwidth
    # note: XPAD corresponds to the hardcoded    #define XPAD 1
    set XPAD 1
    set expected [expr { [font measure [.e cget -font] "xyy"] \
                          + 2 * ( [.e cget -borderwidth] + \
                                [.e cget -highlightthickness] + $XPAD ) } ]
    expr {[winfo reqwidth .e] == $expected}
} -cleanup {
    destroy .e
    unset XPAD expected
} -result {1}

test entry-9.1 {EntryValueChanged procedure} -setup {
    unset -nocomplain x
} -body {
    trace variable x w override
    entry .e -textvariable x -width 0
    .e insert 0 foo

Changes to tests/font.test.

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
test font-4.9 {font command: actual} -constraints {unix noExceed} -body {
    # (objc > 3) so objPtr = objv[3 + skip]
    string tolower [font actual {-family times} -family]
} -result {times}
test font-4.10 {font command: actual} -constraints win -body {
    # (objc > 3) so objPtr = objv[3 + skip]
    font actual {-family times} -family
} -result {Times New Roman}
test font-4.11 {font command: bad option} -body {
    font actual xyz -style
} -returnCodes error -result {bad option "-style": must be -family, -size, -weight, -slant, -underline, or -overstrike}
test font-4.12 {font command: actual} -body {
    font actual {-family times} -- \ud800
} -match glob -result {*}
test font-4.13 {font command: actual} -body {
    font actual {-family times} -- \udc00
} -match glob -result {*}
test font-4.14 {font command: actual} -constraints win -body {
    font actual {-family times} -family -- \ud800\udc00
} -result {Times New Roman}
test font-4.15 {font command: actual} -body {
    font actual {-family times} -- \udc00\ud800
} -returnCodes 1 -match glob -result {expected a single character but got "*"}


test font-5.1 {font command: configure} -body {
    # (objc < 3)







|











|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
test font-4.9 {font command: actual} -constraints {unix noExceed} -body {
    # (objc > 3) so objPtr = objv[3 + skip]
    string tolower [font actual {-family times} -family]
} -result {times}
test font-4.10 {font command: actual} -constraints win -body {
    # (objc > 3) so objPtr = objv[3 + skip]
    font actual {-family times} -family
} -result {times}
test font-4.11 {font command: bad option} -body {
    font actual xyz -style
} -returnCodes error -result {bad option "-style": must be -family, -size, -weight, -slant, -underline, or -overstrike}
test font-4.12 {font command: actual} -body {
    font actual {-family times} -- \ud800
} -match glob -result {*}
test font-4.13 {font command: actual} -body {
    font actual {-family times} -- \udc00
} -match glob -result {*}
test font-4.14 {font command: actual} -constraints win -body {
    font actual {-family times} -family -- \ud800\udc00
} -result {times}
test font-4.15 {font command: actual} -body {
    font actual {-family times} -- \udc00\ud800
} -returnCodes 1 -match glob -result {expected a single character but got "*"}


test font-5.1 {font command: configure} -body {
    # (objc < 3)
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355


test font-45.1 {TkFontGetAliasList: no match} -body {
    font actual {snarky 10} -family
} -result [font actual {-size 10} -family]
test font-45.2 {TkFontGetAliasList: match} -constraints win -body {
    font actual {times 10} -family
} -result {Times New Roman}
test font-45.3 {TkFontGetAliasList: match} -constraints {unix noExceed} -body {
    # can fail on Unix systems that have a real "times new roman" font
    font actual {{times new roman} 10} -family
} -result [font actual {times 10} -family]


test font-46.1 {font actual, with character, no option, no --} -body {







|







2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355


test font-45.1 {TkFontGetAliasList: no match} -body {
    font actual {snarky 10} -family
} -result [font actual {-size 10} -family]
test font-45.2 {TkFontGetAliasList: match} -constraints win -body {
    font actual {times 10} -family
} -result {times}
test font-45.3 {TkFontGetAliasList: match} -constraints {unix noExceed} -body {
    # can fail on Unix systems that have a real "times new roman" font
    font actual {{times new roman} 10} -family
} -result [font actual {times 10} -family]


test font-46.1 {font actual, with character, no option, no --} -body {

Changes to tests/spinbox.test.

2603
2604
2605
2606
2607
2608
2609














2610
2611
2612

2613
2614
2615
2616
2617
2618
2619
2620
    spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
    pack .e
    focus .e
} -body {
    .e insert 0 "xyzzy"
    update
    .e delete 2 4














    winfo reqwidth .e
} -cleanup {
    destroy .e

} -result {42}

test spinbox-9.1 {SpinboxValueChanged procedure} -setup {
    unset -nocomplain x
} -body {
    trace variable x w override
    spinbox .e -textvariable x -width 0
    .e insert 0 foo







>
>
>
>
>
>
>
>
>
>
>
>
>
>
|


>
|







2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
    spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2
    pack .e
    focus .e
} -body {
    .e insert 0 "xyzzy"
    update
    .e delete 2 4
    # To check that deletion actually happened we measure the new width
    # of the widget, based on the measuring width of the remaining text ("xyy")
    # in the widget. For that purpose we have to mirror the code in tkEntry.c
    # for computation of the reqwidth
    # note: XPAD corresponds to the hardcoded    #define XPAD 1
    set XPAD 1
    set buttonWidth [expr { [font measure [.e cget -font] "0"] + 2 * (1 + $XPAD) }]
    if {$buttonWidth < 11} {
        set buttonWidth 11
    }
    set expected [expr { [font measure [.e cget -font] "xyy"] \
                          + 2 * ( [.e cget -borderwidth] + \
                                [.e cget -highlightthickness] + $XPAD ) \
                          + $buttonWidth } ]
    expr {[winfo reqwidth .e] == $expected}
} -cleanup {
    destroy .e
    unset XPAD buttonWidth expected
} -result {1}

test spinbox-9.1 {SpinboxValueChanged procedure} -setup {
    unset -nocomplain x
} -body {
    trace variable x w override
    spinbox .e -textvariable x -width 0
    .e insert 0 foo

Changes to tests/textDisp.test.

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# because some window managers don't allow the overall width of a window
# to get very narrow.

catch {destroy .f .t}
frame .f -width 100 -height 20
pack append . .f left

set fixedFont {Courier -12}
# 15 on XP, 13 on Solaris 8
set fixedHeight [font metrics $fixedFont -linespace]
# 7 on all platforms
set fixedWidth [font measure $fixedFont m]
# 12 on XP
set fixedAscent [font metrics $fixedFont -ascent]
set fixedDiff [expr {$fixedHeight - 13}] ;# 2 on XP







|







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# because some window managers don't allow the overall width of a window
# to get very narrow.

catch {destroy .f .t}
frame .f -width 100 -height 20
pack append . .f left

set fixedFont {"Courier New" -12}
# 15 on XP, 13 on Solaris 8
set fixedHeight [font metrics $fixedFont -linespace]
# 7 on all platforms
set fixedWidth [font measure $fixedFont m]
# 12 on XP
set fixedAscent [font metrics $fixedFont -ascent]
set fixedDiff [expr {$fixedHeight - 13}] ;# 2 on XP

Changes to tests/textWind.test.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
tcltest::loadTestedCommands

# Create entries in the option database to be sure that geometry options
# like border width have predictable values.

option add *Text.borderWidth 2
option add *Text.highlightThickness 2
option add *Text.font {Courier -12}


deleteWindows
# Widget used in tests 1.* - 16.*
text .t -width 30 -height 6 -bd 2 -highlightthickness 2
pack append . .t {top expand fill}
update
.t debug on

# 15 on XP, 13 on Solaris 8
set fixedHeight [font metrics {Courier -12} -linespace]
set fixedDiff [expr {$fixedHeight - 13}] ;# 2 on XP
set color [expr {[winfo depth .t] > 1 ? "green" : "black"}]

wm geometry . {}

# The statements below reset the main window;  it's needed if the window
# manager is mwm to make mwm forget about a previous minimum size setting.







|










|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
tcltest::loadTestedCommands

# Create entries in the option database to be sure that geometry options
# like border width have predictable values.

option add *Text.borderWidth 2
option add *Text.highlightThickness 2
option add *Text.font {"Courier New" -12}


deleteWindows
# Widget used in tests 1.* - 16.*
text .t -width 30 -height 6 -bd 2 -highlightthickness 2
pack append . .t {top expand fill}
update
.t debug on

# 15 on XP, 13 on Solaris 8
set fixedHeight [font metrics {"Courier New" -12} -linespace]
set fixedDiff [expr {$fixedHeight - 13}] ;# 2 on XP
set color [expr {[winfo depth .t] > 1 ? "green" : "black"}]

wm geometry . {}

# The statements below reset the main window;  it's needed if the window
# manager is mwm to make mwm forget about a previous minimum size setting.

Changes to tests/winFont.test.

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    win
} -setup {
    set x {}
} -body {
    lappend x [font actual {-family "Times"} -family]
    lappend x [font actual {-family "New York"} -family]
    lappend x [font actual {-family "Times New Roman"} -family]
} -result {{Times New Roman} {Times New Roman} {Times New Roman}}
test winfont-2.8 {TkpGetFontFromAttributes procedure: Courier fonts} -constraints {
    win
} -setup {
    set x {}
} -body {
    lappend x [font actual {-family "Courier"} -family]
    lappend x [font actual {-family "Monaco"} -family]
    lappend x [font actual {-family "Courier New"} -family]
} -result {{Courier New} {Courier New} {Courier New}}
test winfont-2.9 {TkpGetFontFromAttributes procedure: Helvetica fonts} -constraints {
    win
} -setup {
    set x {}
} -body {
    lappend x [font actual {-family "Helvetica"} -family]
    lappend x [font actual {-family "Geneva"} -family]
    lappend x [font actual {-family "Arial"} -family]
} -result {Arial Arial Arial}
test winfont-2.10 {TkpGetFontFromAttributes procedure: fallback} -constraints {
    win
} -body {
    # No way to get it to fail! Any font name is acceptable.
} -result {}









|








|








|







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    win
} -setup {
    set x {}
} -body {
    lappend x [font actual {-family "Times"} -family]
    lappend x [font actual {-family "New York"} -family]
    lappend x [font actual {-family "Times New Roman"} -family]
} -result {Times Times {Times New Roman}}
test winfont-2.8 {TkpGetFontFromAttributes procedure: Courier fonts} -constraints {
    win
} -setup {
    set x {}
} -body {
    lappend x [font actual {-family "Courier"} -family]
    lappend x [font actual {-family "Monaco"} -family]
    lappend x [font actual {-family "Courier New"} -family]
} -result {Courier Courier {Courier New}}
test winfont-2.9 {TkpGetFontFromAttributes procedure: Helvetica fonts} -constraints {
    win
} -setup {
    set x {}
} -body {
    lappend x [font actual {-family "Helvetica"} -family]
    lappend x [font actual {-family "Geneva"} -family]
    lappend x [font actual {-family "Arial"} -family]
} -result {Helvetica Helvetica Arial}
test winfont-2.10 {TkpGetFontFromAttributes procedure: fallback} -constraints {
    win
} -body {
    # No way to get it to fail! Any font name is acceptable.
} -result {}


Changes to win/tkWinFont.c.

2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
FamilyExists(
    HDC hdc,			/* HDC in which font family will be used. */
    const char *faceName)	/* Font family to query. */
{
    int result;
    Tcl_DString faceString;

    /*
     * Just immediately rule out the following fonts, because they look so
     * ugly on windows. The caller's fallback mechanism will cause the
     * corresponding appropriate TrueType fonts to be selected.
     */

    if (strcasecmp(faceName, "Courier") == 0) {
	return 0;
    }
    if (strcasecmp(faceName, "Times") == 0) {
	return 0;
    }
    if (strcasecmp(faceName, "Helvetica") == 0) {
	return 0;
    }

    Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &faceString);

    /*
     * If the family exists, WinFontExistProc() will be called and
     * EnumFontFamilies() will return whatever WinFontExistProc() returns. If
     * the family doesn't exist, EnumFontFamilies() will just return a
     * non-zero value.







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







2524
2525
2526
2527
2528
2529
2530
















2531
2532
2533
2534
2535
2536
2537
FamilyExists(
    HDC hdc,			/* HDC in which font family will be used. */
    const char *faceName)	/* Font family to query. */
{
    int result;
    Tcl_DString faceString;

















    Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &faceString);

    /*
     * If the family exists, WinFontExistProc() will be called and
     * EnumFontFamilies() will return whatever WinFontExistProc() returns. If
     * the family doesn't exist, EnumFontFamilies() will just return a
     * non-zero value.