Tk Source Code

View Ticket
Login
Ticket UUID: d16587255dd91f3c4ec7901b479b807873a78ece
Title: font.test failures on Linux (the "fixed" font is not fixed-width)
Type: Bug Version: core-8-6-branch
Submitter: fvogel Created on: 2018-09-30 20:10:03
Subsystem: 46. Unix Fonts Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2018-10-06 09:50:06
Resolution: Fixed Closed By: fvogel
    Closed on: 2018-10-06 09:50:06
Description:

Some font.test failures on Linux are due to the fact that the "fixed" font is not fixed-width.

==== font-9.5 font command: measure FAILED
==== Contents of test case:

    # Tk_TextWidth()
    expr {[font measure $fixed "abcdefg"] == [font measure $fixed "a"]*7 }

---- Result was:
0
---- Result should have been (exact matching):
1
==== font-9.5 FAILED



==== font-10.9 font command: metrics: get individual metrics FAILED
==== Contents of test case:

    font metrics $fixed -ascent
    font metrics $fixed -descent
    font metrics $fixed -linespace
    font metrics $fixed -fixed

---- Result was:
0
---- Result should have been (exact matching):
1
==== font-10.9 FAILED

"fixed" is a font provided by xlsfonts() from the OS. It is supposed to be fixed-width however Tk cannot do anything if it's actually not in practice. This font is just provided by the system and happens to be named "fixed".

See also [98db50bdad] which was the same problem, but for macOS.

User Comments: fvogel added on 2018-10-06 09:50:06:
Merged to core-8-6-branch and trunk.

fvogel added on 2018-09-30 21:00:49:

BTW, on the Linux Debian 8 system which shows the problem subject of the present ticket:

% font actual fixed
-family {DejaVu Sans} -size 12 -weight normal -slant roman -underline 0 -overstrike 0
% font metrics fixed
-ascent 22 -descent 6 -linespace 28 -fixed 0

Noticed the -fixed 0 ?


fvogel added on 2018-09-30 20:16:16:

These two tests font-9.5 and font-10.9 pass when switching the font they use from "fixed" to "TkFixedFont", which is a fixed-width font crafted as such specifically for each platform (details in TIP #145, and in library/ttk/fonts.tcl).

Therefore the fix proposal [4f95cf10a8].