Tk Source Code

View Ticket
Ticket UUID: dccd82bdc70dc25bb6709a6c14880a92104dda43
Title: ttk fonts are absolute which is very undesirable for hidpi displays
Type: Bug Version: 8.6.8
Submitter: zeroepoch Created on: 2018-12-07 05:47:41
Subsystem: 88. Themed Tk Assigned To: fvogel
Priority: 5 Medium Severity: Cosmetic
Status: Closed Last Modified: 2020-02-22 15:35:23
Resolution: Fixed Closed By: fvogel
    Closed on: 2020-02-22 15:35:23
In ttk/fonts.tcl under the x11 section it has the following font sizes

	set F(size) -12
	set F(ttsize) -10
	set F(capsize) -14
	set F(fixedsize) -12

From reading the documentation these are absolute font sizes.  When I change these to positive numbers they look much more normal and scale correctly.  The sizes are a little large, but that's another issue.

To workaround this problem I copied this file to ~/.tcl/tclIndex and set TCLLIBPATH=~/.tcl so I could tweak these values without changing the system files.
User Comments: fvogel added on 2020-02-22 15:35:23:
Merged to trunk, following acceptation of the TIP by the TCT.

fvogel added on 2020-02-09 20:08:22:

I have created TIP #564 to gather more feedback on this change.

fvogel added on 2020-02-09 18:15:52:
Sorry, wrong ticket. Please ignore my previous message.

fvogel added on 2020-02-09 18:14:57:
Merged to core-8-6-branch and trunk.

fvogel added on 2020-02-02 09:43:27:
Thanks for the tests Brad.

Definitely I agree with you, I think we can merge this in 8.7 only, since we're still in alpha state here.

bll added on 2020-01-27 15:18:27:
Sizes are reasonable.

MX Linux (debian 19) with screen size set.
MX Linux without screen size set.
Fedora 27 (Wayland) where WidthOfScreenMM returns 0.

bll added on 2020-01-26 21:55:01:
For 8.7 is correct.

I want to do one test w/X11 when the screen size is not known and see what
happens.   I will try to get that done tomorrow.

fvogel added on 2020-01-26 20:27:01:

I have committed the patch in a bugfix branch, see [b441746a60].

Despite I see this as a bug fix, I think this has a potential for backwards incompatibility and should be applied in trunk (aka 8.7) but not in the maintenance branch of 8.6 (i.e. not in core-8-6-branch). If ayone disagrees, please speak up.

In the process I have removed Joe's original comment saying that

#	Font size specified in pixels on X11, not points.
#	This is Theoretically Wrong, but in practice works better; using
#	points leads to huge inconsistencies across different servers.

This comment (and font sizes in pixels) apparently does no longer apply, users are now rather complaining about sizes in pixels on x11.

On Windows and macOS Ttk font sizes already are set in points in library/ttk/fonts.tcl so there is nothing to change.

What I need to better understand is why this code section in library/ttk/fonts.tcl is executed whereas TIP #145 was included a long time ago. There is a detection mechanism that should prevent this code from being executed.

zeroepoch added on 2020-01-16 06:34:21:
Fedora is now carrying this patch in their tk package as well.  Between Ubuntu and Fedora that would cover a large percentage of Linux desktop users.

zeroepoch added on 2020-01-09 07:19:58:
Interesting.  That's exactly the same change I made locally, even the same sizes!  I had no idea someone from the Debian team made this change almost 9 months before I even created this bug.  Nice to see Debian/Ubuntu has been changing the default point sizes for their users.  Any chance we could get this applied upstream?

bll added on 2019-12-18 13:49:30:
See also:

I'm not against this.  All for it.
tk scaling does not work on pixel-sized fonts.

zeroepoch added on 2019-12-18 07:39:22:

I'm not so sure that using an absolute point size makes sense.  It would make more sense to use the relative point size so it does some amount of scaling.  Or at least use relative when point size scaling can be resolved.  If you had a really high DPI display such as a phone or tablet it might be 3x or 4x the original size and it would be much too small to read.  I'm not any sort of expert on this, just discovered one possible workaround which was to use relative point sizes.  Maybe there is some better way to fix this, such as tk scaling, which I'm not at all familiar with.  Thanks for at least commenting on this issue.

bll added on 2018-12-07 06:48:01:
Yes, they're not a great choice of defaults.
But they always work, even when the screen size is unknown and the size of 
a point cannot be determined properly.
More historical than anything.

See also: tk scaling

zeroepoch added on 2018-12-07 06:24:15:
For anyone reading this ticket you need to add the following line as the first line in the tclIndex file for it to be accepted:

# Tcl autoload index file, version 2.0