Ticket UUID: | 1fba28d328b00704236b4a9ea8f32204ce89a8a7 | |||
Title: | No high dpi support on X11 | |||
Type: | Bug | Version: | 8.6.7 | |
Submitter: | joshua.kraemer | Created on: | 2018-03-30 13:27:39 | |
Subsystem: | 02. Appearance | Assigned To: | nobody | |
Priority: | 5 Medium | Severity: | Severe | |
Status: | Open | Last Modified: | 2023-09-15 16:39:34 | |
Resolution: | None | Closed By: | nobody | |
Closed on: | ||||
Description: |
On X11, Tk does not adapt to the display's dpi value. On a high-dpi display, most widget elements are rendered much too small. This is how some of the widgets appear on my 192 dpi monitor (default widgets at the top, Ttk widgets with classic theme at the bottom): Default widgets: At least the font size is appropriate and the menu button indicator is scaled, everything else is too small. Ttk widgets: Everything is too small, the tiny text is unreadable at normal viewing distance. I consider this to be severe, because in the current state, Tk applications are nearly unusable on X11 systems with high-dpi displays. | |||
User Comments: |
nemethi (claiming to be Csaba Nemethi) added on 2023-09-15 16:39:34:
I have prepended "ttk::" to "scrollbar" in the last line of the original test script and passed the patched script to a wish freshly built from trunk, in an X11 environment in which the DPI scaling level was set in the system settings to 200 %. The attached screenshots "test_classic.png" and "test_default.png", corresponding to the Ttk themes "classic" and "default", demonstrate that the widgets are now scaling-aware, meaning that their sizes are automatically adapted to the display's DPI scaling level. kjnash added on 2023-08-24 14:39:44: There is a bug [1de3a48312] in Tk's use of FreeType on X11 systems. Tk ignores [tk scaling] for fonts sized in points; and incorrectly alters fonts sized in pixels. cjmcdonald added on 2020-05-06 13:48:58: The font size part of this ticket was addressed in [dccd82bdc7] and TIP #564, specifying default font sizes in points instead of pixels. bll added on 2019-05-30 20:40:49: ttk::style configure Treeview -rowheight [expr {[font metrics namedfont -linespace] + 2}] bll added on 2019-05-30 19:57:38: That's a known problem with the treeview widget and exists when the font of the treeview widget is changed. There's another ticket somewhere for it. jal_frezie added on 2019-05-30 18:13:50: One thing that doesn't work is the ttk::treeview widget. If you set a high DPI, the font of the labels gets larger as it should, but the vertical spacing of the entries does not change, with the result that you can only see the top half of each line of text (I'm using TclTk 8.6.8, apologies if that has since been fixed) bll added on 2018-04-02 18:18:43: From the test script, I am guessing that TkDefaultFont is incorrectly specified as a pixel size rather than in points. I would open a separate ticket for that issue, as this ticket has too broad of a scope. I have attached another script with the styles configured to use a named font. bll added on 2018-04-02 17:14:25: Are your font sizes specified in pixels or points? I have not seen any trouble with font scaling with my limited high DPI testing. If the screen size is specified in Xorg.conf, the way X11 draws elements may change. Unfortunately, nobody has spent time working on the widgets and making them work properly with higher DPI settings. Most likely, those thin line borders are specified in pixel sizes instead of points and do not scale. Any border elements you have control over may be specified in points rather than pixels and hopefully will scale properly. What Tk needs is a set of widgets written to use a full-featured SVG library. Most of the Tcl/Tk coders seem to avoid adding third-party dependencies even when the functionality is much needed. Even though Tcl/Tk is quite capable of dynamically loading said functionality without a hard dependency. If Tk had transparent backgrounds, I could write scalable widgets much easier, but it always draws a background for label widgets. Maybe I will have time to start work on that next year. joshua.kraemer (claiming to be joshua) added on 2018-04-02 16:38:06:
The scaling factor is already correctly set to "2.6666666666666665". However, it is obviously ignored by most widget elements. Elements are rendered as thin 1px lines, while they should be scaled by the scaling factor. I expect at least the default Tk theme to adapt to the display's dpi. In fact, I have tried many different Ttk themes (default, classic, alt, clam, themes from the web) and none of them was scaled correctly. Thank you for the hint with your scalable checkbox widget. However, the default widgets should be scaled correctly. It should not be necessary as an application user to exchange widgets to be able to run a Tk program on modern hardware! In contrast, Qt 5 applications show much better high-dpi support. Elements are rendered with too thin lines as well. But otherwise, all fonts and widgets are scaled correctly: Qt screenshot. bll added on 2018-03-30 14:17:21: In fact, Tk is one of the few applications that does have proper high DPI support. Please look up: tk scaling https://www.tcl.tk/man/tcl/TkCmd/tk.htm http://wiki.tcl.tk/8484 Unfortunately, many of the ttk themes have graphical components, and these do not scale properly. I am less than enamored of the methods seen in Windows and Ubuntu and Gnome 3 for supporting high DPI. Windows does not have proper high DPI support, and its graphic components also do not scale properly. Not sure about the state of Mac OS X. I also made some notes (in a more general sense): http://wiki.tcl.tk/41773 And I made a non-graphical scaled checkbutton: http://wiki.tcl.tk/44212 (horrible code, but it works) |
Attachments:
- test_default.png [download] added by nemethi on 2023-09-15 16:16:49. [details]
- test_classic.png [download] added by nemethi on 2023-09-15 16:16:32. [details]
- hd.tcl [download] added by bll on 2018-04-02 18:16:42. [details]
- test.tcl [download] added by joshua.kraemer on 2018-04-02 17:00:49. [details]