This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: IDLE: Tiny font on HiDPI display
Type: behavior Stage: resolved
Components: IDLE Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: cheryl.sabella, louielu, ned.deily, serhiy.storchaka, taleinat, terry.reedy
Priority: normal Keywords: patch

Created on 2017-09-17 18:54 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
Screenshot_20170917_213616.png serhiy.storchaka, 2017-09-17 18:54
configdialogkeys_old.png cheryl.sabella, 2017-09-18 16:20
configdialogkeys_new.png cheryl.sabella, 2017-09-18 16:22
configkey_2.png cheryl.sabella, 2017-09-20 00:32
Pull Requests
URL Status Linked Edit
PR 3639 merged serhiy.storchaka, 2017-09-18 07:45
PR 3664 merged terry.reedy, 2017-09-19 22:20
PR 3665 merged python-dev, 2017-09-19 23:02
PR 3686 merged terry.reedy, 2017-09-21 14:52
PR 6585 merged cheryl.sabella, 2018-04-24 00:34
PR 10015 merged terry.reedy, 2018-10-20 21:08
Messages (32)
msg302381 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-17 18:54
My new laptop has a HiDPI display (3840x2160). IDLE (as well as other Tk applications) looks ugly on it. The font of menu and dialogs is tiny. The font used in editor and shell looks normal size. I use Linux with X Window.

It seems to me this issue doesn't have solution. Related links:
msg302417 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-18 08:01
PR 3639 adapts the receipt from [1]. I'm not sure that it doesn't add regressions on low-DPI displays.

msg302463 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-18 15:32
The TkFixedFont initially used in Shell and editor has its size set to 10 if initially negative. Users can only replace this with a real font, not another of tk's abstract fonts.

On windows, the sizes of the nearly 20 fonts touched by the patch range from 8 to 12.  So no possible regression there.  If the sizes on Linux were in the range -8 to -12, then the effect is to replace the size with numbers around 10 instead of exactly 10 (as IDLE currently does).  But from what you said on the patch, the negative numbers are not exactly the negative of their real size, but are tuned for positioning.

Cheryy, Louie, and Ned: the patch needs to be test on multiple *nix machines, especially on OSX, to make sure it does not mess up on standard monitors.  A quick 'git pr 3639' and 'python -m test.test_idle' would be helpful.
msg302464 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2017-09-18 15:48
Tests run on Ubuntu.  The menubar is bigger now though, so it's default is
different than before.  Maybe that was the only way to fix it, but it's now
about twice as big as the shell font.
msg302471 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2017-09-18 16:20
Attached screen prints of configdialog.  It's messed up.
msg302477 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-18 18:23
Thank you Cheryl.  That is enough to reject the patch is it is now.

The negative sizes are pixels.  I think it might be better to multiply them by a systems specific factor, but only when needed.

One might wish that the scaling should be handled automatically, in tkinter if not in tk itself.  But it was mentioned in one of the links that displays do not always report their dpi correctly.

One possibility is a tkinter calibration app that displays a 500 or 1000 pixel line (user selects) and asks the user to input the physical length (centimeters or inches).  (Some games do something similar with brightness.)

To check whether a tkinter scaling app could be used, I sized Serhiy's image so that the sample font in the Settings Font tab matched the sample font in a real box.  The system font around it is tiny but readable, especially with a magnifier.

This is a tkinter issue, not only an IDLE issue, but IDLE is a good test app, with realistically complex dialogs. Lacking a Python-wide fix, something could be added to the Font tab -- for instance a dpi multiplier that defaults to one.  It would only be used if not 1.0.

I reread config.IdleConf.GetFont.  Rather than manipulate one of tk's default fonts ('TkFixedFont'), it creates a normal font sized in points.  It uses 'TkFixedFont' as a handy key for finding a system-specific sure-to-exist fixed pitch font: "actualFont = Font.actual(f)", where f is a TkFixedFont instance.  Thus it does not affect the dialogs.

It would be helpful to know if HiDPI screens on Windows have a problem.

#31496 is about test_configdialog failing on the same HiDPI screen.
msg302509 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-19 08:36
The Keys and General tabs are messed up even more on my computer. Some sections are just not visible. This is because The dialog window uses hardcoded size in pixels, it is too small for all content. After removing the hardcoded size all looks good.
msg302563 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-19 21:56
Cheryl, what do you get with

import tkinter as tk
root = tk.Tk()
print(float('tk', 'scaling')))

If it is less than 1.2, then Serhiy's revised patch should leave config dialog as it should be.
msg302566 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-19 23:01
New changeset d6e2f26f3f7c62a4ddbf668027d3ba27cb0e1eca by Terry Jan Reedy in branch 'master':
bpo-31500: Removed fixed size of IDLE config dialog. (#3664)
msg302572 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-19 23:45
New changeset 97be14996b247b853ead77fb255d7029e3cf3dc9 by Terry Jan Reedy (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-31500: Removed fixed size of IDLE config dialog. (GH-3664) (#3665)
msg302573 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2017-09-20 00:24
>>> import tkinter as tk
>>> root = tk.Tk()
>>> print(float('tk', 'scaling')))
msg302574 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2017-09-20 00:32
configdialog looks better now, but the fonts are still huge.  The configdialog is almost bigger than the shell when it opens.
msg302579 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-20 01:25
It appears that the cutoff of 1.2 in the patch is too low.  Try raising it to 1.4 and you should see the dialog normal.
msg302580 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-20 01:30
I mean '  if scaling >= 1.2:' in run.fix_scaling.  It would also be interesting to instead replace the last line,  "font['size'] = -size" with "font['size'] = 9" (or 8 or 10) and see how close the dialog is to what is was before.
msg302595 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-20 05:58
If just negate the size the menu and the dialog fonts look like on a display with 72 DPI. But currently monitors rarely have such DPI. Normal displays have about 100 DPI (scaling factor about 1.33). If we want to keep font sizes on such displays we should multiply sizes by 0.75 for converting from pixels to points.
msg302605 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-20 08:45
My screen is 23.5 x 13.25, making it 109 DPI.  I asked Cheryl to try 9 first because it is 3/4 of 12.
msg302607 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2017-09-20 12:04
The scaling factor of 1.4 worked and the menu and configdialog looked normal.

font['size'] = 9 also worked as did font['size'] = 10.  font['size'] = 12 is when it's too big.
msg302640 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-20 17:18
The limit 1.4 is not arbitrary. This is a minimal scale for which fonts from 10 to 14 pixels are not decreased when converted to points (with multiplier 0.75 and one rounding). round(14 * 0.75) = round(10.5) = 10; 10 * 1.4 = 14.
msg302672 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-21 08:20
New changeset a96c96f5dab68d4e611af4b8caefd7268533fd9a by Serhiy Storchaka in branch 'master':
bpo-31500: IDLE: Scale default fonts on HiDPI displays. (#3639)
msg302695 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-09-21 15:15
New changeset 0c4997f1919d8583353b12537a63dcbe7b9d280f by Terry Jan Reedy in branch '3.6':
[3.6] bpo-31500: IDLE: Scale default fonts on HiDPI displays. (GH-3639) (#3686)
msg313199 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-03-04 05:41
I assume that the 2nd patch, by Serhiy, fixed the issue.
msg313204 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-04 07:41
What about 2.7?
msg313206 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-03-04 09:18
I take it you want this reopened.  I have not touched IDLE 2.7 for over a year, but since a) there have been no complaints about the patch in released 3.6.3/4, b) we recommend the same tk 8.5.18 for both 2.7 and 3.6, and c) this is a crippling regression upon equipment upgrade, I will review and manually test on Windows a combined backport of both PRs first tested on a Linux or Mac system.  It should be tested on a HiDPI system before a merge.
msg315664 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-04-23 12:32
I guess I was not clear enough that I will test on Windows after someone else does a backport that works on Linux.
msg315666 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-04-23 12:54
You promised to make backports to 2.7 when did the mass files renaming. The simple cherry-picking doesn't work, and I even don't know what files in 2.7 should be changed.
msg316455 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-13 08:38
Something was changed on my computer (I upgraded the OS twice since creating this issue), and now I don't see any difference between patched and unpatched 2.7. Terry, could you please test whether there are any visible effects on Windows?
msg316485 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-05-14 00:47
Does IDLE now work on your HiDPI screen without the patch? or does it not work even with the patch?  

I just got a 2.7 worktree working with Python built.  2.7.15+ comes with 8.5.19 instead of 8.5.15.  IDLE runs as I expect and windows look normal, as with 3.x, both before and after the patch.  

If calling fix_scaling ever causes anyone a problem on some particular combination of OS, Python, and Tk versions, they could neutralize it by adding the following after the current definition.

def fix_scaling: pass
msg316506 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-14 14:15
Seems IDLE now works on my HiDPI screen without the patch. It looks the same as IDLE in 3.x with the patch.
msg316574 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-05-14 20:53
My inclination, then, is to close this issue and PR until there is a demonstrated need for change and a test machine to verify the fix for 2.7 and 8.5.19.
msg328177 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-10-20 20:27
New changeset 18c44cc0c13eed792e286ddc1d331951e723aeb9 by Terry Jan Reedy (Cheryl Sabella) in branch '2.7':
[2.7] bpo-31500: IDLE: Scale default fonts on HiDPI displays. (GH-3639) (GH-6585)
msg328182 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-10-20 23:34
New changeset f125d788ff71095390a9e190da6722eb00166cd4 by Terry Jan Reedy in branch '2.7':
bpo-31500: Default fonts now are scaled on HiDPI displays. (#10015)
msg328200 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2018-10-21 09:05
Just tested on a 13" Retina MacBook Pro (2560x1600), everything looks fine.
Date User Action Args
2022-04-11 14:58:52adminsetgithub: 75681
2018-10-21 09:05:30taleinatsetnosy: + taleinat
messages: + msg328200
2018-10-20 23:35:31terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-10-20 23:34:16terry.reedysetmessages: + msg328182
2018-10-20 21:08:57terry.reedysetpull_requests: + pull_request9352
2018-10-20 20:27:56terry.reedysetmessages: + msg328177
2018-05-14 20:53:42terry.reedysetmessages: + msg316574
2018-05-14 14:15:01serhiy.storchakasetmessages: + msg316506
2018-05-14 00:47:25terry.reedysetmessages: + msg316485
2018-05-13 08:38:56serhiy.storchakasetmessages: + msg316455
2018-04-24 00:34:19cheryl.sabellasetstage: needs patch -> patch review
pull_requests: + pull_request6284
2018-04-23 12:54:32serhiy.storchakasetmessages: + msg315666
2018-04-23 12:32:22terry.reedysetmessages: + msg315664
2018-03-04 09:18:51terry.reedysetstatus: closed -> open
versions: - Python 3.6, Python 3.7
messages: + msg313206

resolution: fixed -> (no value)
stage: resolved -> needs patch
2018-03-04 07:41:58serhiy.storchakasetmessages: + msg313204
2018-03-04 05:41:38terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg313199

stage: patch review -> resolved
2017-09-21 15:15:48terry.reedysetmessages: + msg302695
2017-09-21 14:52:33terry.reedysetpull_requests: + pull_request3675
2017-09-21 08:20:12serhiy.storchakasetmessages: + msg302672
2017-09-20 17:18:18serhiy.storchakasetmessages: + msg302640
2017-09-20 12:04:51cheryl.sabellasetmessages: + msg302607
2017-09-20 08:45:09terry.reedysetmessages: + msg302605
2017-09-20 05:58:26serhiy.storchakasetmessages: + msg302595
2017-09-20 01:30:27terry.reedysetmessages: + msg302580
2017-09-20 01:25:31terry.reedysetmessages: + msg302579
2017-09-20 00:32:19cheryl.sabellasetfiles: + configkey_2.png

messages: + msg302574
2017-09-20 00:24:39cheryl.sabellasetmessages: + msg302573
2017-09-19 23:45:06terry.reedysetmessages: + msg302572
2017-09-19 23:02:01python-devsetpull_requests: + pull_request3654
2017-09-19 23:01:49terry.reedysetmessages: + msg302566
2017-09-19 22:20:46terry.reedysetpull_requests: + pull_request3653
2017-09-19 21:56:55terry.reedysetmessages: + msg302563
2017-09-19 08:36:25serhiy.storchakasetmessages: + msg302509
2017-09-18 18:23:36terry.reedysetmessages: + msg302477
2017-09-18 16:22:45cheryl.sabellasetfiles: + configdialogkeys_new.png
2017-09-18 16:21:39cheryl.sabellasetfiles: - configdialog_new.png
2017-09-18 16:20:49cheryl.sabellasetfiles: + configdialogkeys_old.png
2017-09-18 16:20:34cheryl.sabellasetfiles: + configdialog_new.png

messages: + msg302471
2017-09-18 15:48:18cheryl.sabellasetmessages: + msg302464
2017-09-18 15:32:33terry.reedysetnosy: + ned.deily, louielu, cheryl.sabella
messages: + msg302463
2017-09-18 08:01:27serhiy.storchakasetmessages: + msg302417
2017-09-18 07:45:46serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request3633
2017-09-17 18:54:06serhiy.storchakacreate