Tk Source Code

View Ticket
Login
Ticket UUID: 98db50bdadf0df78e503c173d8f69b22f22e5d73
Title: OS X - unixFont.test failures ("fixed" font is not fixed-width)
Type: Bug Version: core-8-6-branch
Submitter: fvogel Created on: 2017-01-02 13:34:11
Subsystem: 86. Test Tools Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2017-12-10 17:06:01
Resolution: Fixed Closed By: fvogel
    Closed on: 2017-12-10 17:06:01
Description:

On OS X, the test suite runs unixFont.test among other tests. Some tests of this file fail.

Looking specifically at unixfont-5.12, I have found that the failure is due to the "fixed" named font selected for the label widget is not actually fixed-width.

% package require Tk
% label .l -padx 0 -pady 0 -bd 0 -highlightthickness 0 -justify left -text "0" -font fixed
.l
% pack .l]
% font actual fixed
-family .AppleSystemUIFont -size 13 -weight normal -slant roman -underline 0 -overstrike 0
% font metrics fixed
-ascent 13 -descent 3 -linespace 16 -fixed 0

Note the "-fixed 0" in the output.

I believe that most, if not all, failures of the unixFont.test file are due to this cause.

Detailed failures output:

unixFont.test


==== unixfont-1.2 TkpGetNativeFont procedure: native FAILED
==== Contents of test case:

    font measure fixed 0

---- Result was:
9
---- Result should have been (exact matching):
6
==== unixfont-1.2 FAILED



==== unixfont-2.6 TkpGetFontFromAttributes: fallback to fixed family FAILED
==== Contents of test case:

    lindex [font actual {-family fixed -size 10}] 1

---- Result was:
.AppleSystemUIFont
---- Result should have been (exact matching):
fixed
==== unixfont-2.6 FAILED



==== unixfont-2.8 TkpGetFontFromAttributes: loop over returned font names FAILED
==== Contents of test case:

    lindex [font actual {-family fixed -size 31}] 1

---- Result was:
.AppleSystemUIFont
---- Result should have been (exact matching):
fixed
==== unixfont-2.8 FAILED



==== unixfont-2.9 TkpGetFontFromAttributes: reject adobe courier if possible FAILED
==== Contents of test case:

    lindex [font actual {-family courier}] 1

---- Result was:
Courier
---- Result should have been (exact matching):
courier
==== unixfont-2.9 FAILED



==== unixfont-5.4 Tk_MeasureChars procedure: reached right edge FAILED
==== Contents of test case:

    .b.l config -text "0000000000000"
    getsize

---- Result was:
90 34
---- Result should have been (exact matching):
90 36
==== unixfont-5.4 FAILED



==== unixfont-5.5 Tk_MeasureChars procedure: ran out of chars FAILED
==== Contents of test case:

    .b.l config -text "000000"
    getsize

---- Result was:
49 18
---- Result should have been (exact matching):
54 18
==== unixfont-5.5 FAILED



==== unixfont-5.6 Tk_MeasureChars procedure: find last word FAILED
==== Contents of test case:

    .b.l config -text "000000 00000"
    getsize

---- Result was:
49 34
---- Result should have been (exact matching):
54 36
==== unixfont-5.6 FAILED



==== unixfont-5.7 Tk_MeasureChars procedure: already saw space in line FAILED
==== Contents of test case:

    .b.l config -text "000000     00000"
    getsize

---- Result was:
49 34
---- Result should have been (exact matching):
54 36
==== unixfont-5.7 FAILED



==== unixfont-5.8 Tk_MeasureChars procedure: internal spaces significant FAILED
==== Contents of test case:

    .b.l config -text "00  000     00000"
    getsize

---- Result was:
48 34
---- Result should have been (exact matching):
63 36
==== unixfont-5.8 FAILED



==== unixfont-5.9 Tk_MeasureChars procedure: TK_PARTIAL_OK FAILED
==== Contents of test case:

    .b.c dchars $t 0 end
    .b.c insert $t 0 "0000"
    .b.c index $t @[expr int($ax*2.5)],1

---- Result was:
3
---- Result should have been (exact matching):
2
==== unixfont-5.9 FAILED



==== unixfont-5.10 Tk_MeasureChars procedure: TK_AT_LEAST_ONE FAILED
==== Contents of test case:

    .b.l config -text "000000000000"
    getsize

---- Result was:
90 34
---- Result should have been (exact matching):
90 36
==== unixfont-5.10 FAILED



==== unixfont-5.11 Tk_MeasureChars: TK_AT_LEAST_ONE + not even one char fit! FAILED
==== Contents of test case:

    set a [.b.l cget -wrap]
    .b.l config -text "000000" -wrap 1
    set x [getsize]
    .b.l config -wrap $a
    set x

---- Result was:
9 98
---- Result should have been (exact matching):
9 108
==== unixfont-5.11 FAILED



==== unixfont-5.12 Tk_MeasureChars procedure: include eol spaces FAILED
==== Contents of test case:

    .b.l config -text "000   \n000"
    getsize

---- Result was:
25 50
---- Result should have been (exact matching):
54 36
==== unixfont-5.12 FAILED



==== unixfont-8.4 AllocFont procedure: classify characters FAILED
==== Contents of test case:

    set x 0
    incr x [font measure $courier "\u4000"]   ;# 6
    incr x [font measure $courier "\002"]   ;# 4
    incr x [font measure $courier "\012"]   ;# 2
    incr x [font measure $courier "\101"]   ;# 1
    set x

---- Result was:
22
---- Result should have been (exact matching):
78
==== unixfont-8.4 FAILED



==== unixfont-8.6 AllocFont procedure: setup widths of special chars FAILED
==== Contents of test case:

    set x 0
    incr x [font measure $courier "\001"]   ;# 4
    incr x [font measure $courier "\002"]   ;# 4
    incr x [font measure $courier "\012"]   ;# 2
    set x

---- Result was:
6
---- Result should have been (exact matching):
60
==== unixfont-8.6 FAILED



==== unixfont-9.1 GetControlCharSubst procedure: 2 chars subst FAILED
==== Contents of test case:

    .b.c dchars $t 0 end
    .b.c insert $t 0 "0\a0"
    set x {}
    lappend x [.b.c index $t @[expr $ax*0],0]
    lappend x [.b.c index $t @[expr $ax*1],0]
    lappend x [.b.c index $t @[expr $ax*2],0]
    lappend x [.b.c index $t @[expr $ax*3],0]

---- Result was:
0 2 3 3
---- Result should have been (exact matching):
0 1 1 2
==== unixfont-9.1 FAILED



==== unixfont-9.2 GetControlCharSubst procedure: 4 chars subst FAILED
==== Contents of test case:

    .b.c dchars $t 0 end
    .b.c insert $t 0 "0\0010"
    set x {}
    lappend x [.b.c index $t @[expr $ax*0],0]
    lappend x [.b.c index $t @[expr $ax*1],0]
    lappend x [.b.c index $t @[expr $ax*2],0]
    lappend x [.b.c index $t @[expr $ax*3],0]
    lappend x [.b.c index $t @[expr $ax*4],0]
    lappend x [.b.c index $t @[expr $ax*5],0]

---- Result was:
0 2 3 3 3 3
---- Result should have been (exact matching):
0 1 1 1 1 2
==== unixfont-9.2 FAILED

User Comments: fvogel added on 2017-12-10 17:06:01:
Merged to core-8-6-branch and trunk

fvogel added on 2017-12-09 16:58:41:

Just using TkFixedFont instead of 'fixed' does not bring any improvement.

Looking closely at these tests it appears they are really targeted to Linux and only Linux. They are based on a "fixed" font, which is fixed-width and which actual name and size are specific. These tests should just no run on MacOS, as is already the case regarding Win.

Fix proposed in [32b9fb26]: use 'x11' constraint with all tests of unixFont.test, instead of 'unix' constraint'.


fvogel added on 2017-12-06 21:47:58:

Same issue in another test in ttk::entry, see [43e38f1bcc].


bll added on 2017-01-02 14:10:49:
Just an addendum.
The ttk widgets do choose a fixed font correctly on the mac (using TkFixedFont).
(So apparently there must be duplicated code for choosing fixed fonts?)

bll-mac:bll$ rlwrap tclsh
% package require Tk
8.6.6
% font actual TkFixedFont 
-family Monaco -size 11 -weight normal -slant roman -underline 0 -overstrike 0
% font metrics TkFixedFont
-ascent 12 -descent 3 -linespace 15 -fixed 1
%