Tk Source Code

View Ticket
Login
Ticket UUID: eb1c56bf514e418bbfcd0f05e514fa061b88e65d
Title: Font size follows Xft.dpi (XWayland, 133% scale), but "tk scaling" and winfo_fpixels do not reflect it
Type: Bug Version: 8.6
Submitter: anonymous Created on: 2026-10-02 08:49:47
Subsystem: 15. [scale] Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-10-02 10:03:55
Resolution: None Closed By: nobody
    Closed on:
Description:
Observation: At 100% display scale Xft.dpi is 96, at 133% it is 192 (xrdb -query).
Text in a plain Tk app doubles in size, but pixel geometry (canvas, padx, ...)
does not. Leaving the layout of apps like noScribe crammed and broken.


Workaround: echo "Xft.dpi: 96" | xrdb -merge before starting the app restores
normal font sizes and fixes the layout.

Measurments with the script bellow:
Measured (same script, run at each setting):
              100%    133%
text width      98     194   (Roboto, size 14)
linespace       23      45
pixel font     99     202   
button width  140     239   (padx=20)
canvas width  300     300

Values that stay the same in both runs:
  tk scaling              1.335 / 1.334
  winfo_fpixels('1i')     96.14 / 96.04
Setting "tk scaling 1.0" does not change the font size at 133%.
(winfo_screenwidth changes: 2256 vs 3384.)

Questions:
1. Is it intended that font rendering follows Xft.dpi independently of "tk scaling"
   and of winfo_fpixels?
2. Is there a supported way for an application to detect the factor that is
   applied to fonts? (Applications that lay out in pixels cannot compensate.)
User Comments: oehhar added on 2026-10-02 10:03:55:

This is a known limitation of Tk 8.6 which was fixed in tk 9.x. There "tk scaling" initialization from the Window manager is highly improved. And nearly all Widgets are now scaling aware.

To implement your solution of setting the scaling within the script, add "tk scaling <value>" before any widget creation.

But testing is always great, as this depends on the Widnows Manager. Does this work for you?

This will not be back-ported to 8.6.

Also, CTK was highly improved in 9.1.0. It would be great to test this and report back. Remark, that there are also bugfixes in the main branch of tk.

Take care, Harald


anonymous added on 2026-10-02 08:52:37:
see also the effects on CTK https://github.com/TomSchimansky/CustomTkinter/issues/2870

Attachments: