New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better default font for editor #68933
Comments
By default, IDLE chooses courier for the text editor font. As you'll see from the attached screenshot, while this looks ok on Windows, it's inconsistent with the standard fixed width fonts on Linux and OS X, and borders on unreadable particularly on the latter. While this can be changed via the configuration dialog (the 'fixed' versions in the screenshots do just that), this is one of the things that really jumps out at you the first time you run IDLE, and not in a good way. Tk defines a font named 'TkFixedFont', which we should take advantage of instead of hardcoding courier; details of the font can be retrieved via
Note there's a bit of an overlap here with #<20580>, but suggests that there may be some cases where determining defaults programmatically rather than hardcoding multiple defaults may be appropriate. |
I agree that Courier is ugly and a bad thing to hardcode. I long ago switched to Lucida Console, which other than i and l is very close to the Mac/linux examples. I had forgotten that Courier was the default. Ned, am I correct in thinking you would like this? Mark, please submit a patch. Too bad that tk does not use something better for Windows too, but I agree that Courier is least bad here. PS. Leave brackets off issue references like bpo-20580 so they become links. The overlap is minimal; in any case, that issue will need several patches and subissues. |
With current ActiveTcl 8.5.18 on OS X, "TkFixedFont" translates to Monaco 11 point which looks fine on my laptop. I don't have a Retina display handy to see how it looks there but it's probably an improvement over Courier so changing the default sounds good to me. |
Quick question how best to represent this in the config-main.def file. My thought is to leave a "font=" line there so that the GetOption call returns an empty string. The editor code can then detect that and substitute TkFixedFont. Would this break anything and/or would there be a more preferred approach? |
For the benefit of anyone reading the file, I would prefer "font = TkFixedFont", though I notice that LoadFontConfig has a backup default. Just as important, I think: IDLE Preferences => Font/Tabs => Editor Base Font needs a [Default] button so people can unselect a non-default selection without remembering what the default was. Other changes (re-arrangements) are needed to use the space better, but for now, I think increasing the height to make room would be sufficient. Or perhaps 'TkFixedFont could be added to the top of the list before adding the sorted list of those available. The tricky issue is this: when a user changes a setting, the change is saved to a change dictionary. When [Apply] or [OK] are clicked, the new values are compared to the defaults and non-defaults are written to the user file. (Some files get sets of values written). So a user needs to be able to select 'TkFixedFont' to avoid having a specific font written to the user file (which might be the only item in the file, and which would override a future change to the binding of TkFixedFont). |
I'm ok with putting TkFixedFont in the config file. Only potential downside I see is that the code will look for this specific value, but people may read the config file and assume it could be changed to any Tk*Font. I'd strongly argue against putting in a default button and/or including TkFixedFont in the list for the following reasons:
Is there actually a downside to writing out the per-user config file even if there isn't a "real" change in the font? |
I've attached defaultfont.patch which will look for the magic value 'TkFixedFont' in the configuration file and do some appropriate magic with it. Most of the font handling smarts are now in a 'GetFont' call in configHandler, which as a bonus reduces some of the complexity and duplication elsewhere. |
New changeset 55e5f7766d2c by Terry Jan Reedy in branch '2.7': New changeset 5c992189414f by Terry Jan Reedy in branch '3.4': New changeset 90c02a0bec08 by Terry Jan Reedy in branch '3.5': New changeset 3a731756f9cc by Terry Jan Reedy in branch 'default': |
Review published with the changes I made, tested, and committed. I am not convinced that writing all 3 font attributes is needed, which is good since existing user files do not have all 3. But safer for future. Part of my preference to avoid user file when not needed (because only config matches default) is because user files are an occasional point of failure. But we should fix bugs noted in TODOs and on tracker. |
New changeset 82198ae039cd by Terry Jan Reedy in branch '3.4': New changeset bf14b74d6fc0 by Terry Jan Reedy in branch '3.5': New changeset 5744985ad8dc by Terry Jan Reedy in branch '2.7': |
Unfortunately, we didn't test this change with Tk 8.4: TkFixedFont does not exist in 8.4. This means that, unless the user has already modified the IDLE configuration to use an explicit font, IDLE linked with Tk 8.4 crashes in initialization. $ mv .idlerc/ .idlerc-OLD
$ idle3.5
Traceback (most recent call last):
File "/usr/local/bin/idle3.5", line 5, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/idlelib/PyShell.py", line 1560, in main
shell = flist.open_shell()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/idlelib/PyShell.py", line 320, in open_shell
self.pyshell = PyShell(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/idlelib/PyShell.py", line 867, in __init__
OutputWindow.__init__(self, flist, None, None)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/idlelib/OutputWindow.py", line 16, in __init__
EditorWindow.__init__(self, *args)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/idlelib/EditorWindow.py", line 233, in __init__
text['font'] = idleConf.GetFont(self.root, 'main', 'EditorWindow')
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/idlelib/configHandler.py", line 691, in GetFont
f = Font(name='TkFixedFont', exists=True, root=root)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/tkinter/font.py", line 87, in __init__
"named font %s does not already exist" % (self.name,))
_tkinter.TclError: named font TkFixedFont does not already exist
n A workaround is to manually create or edit the IDLE configuration file and define an explicit font, for example on OS X: $ cat > ~/.idlerc/config-main.cfg <<EOF
[EditorWindow]
font-size = 11
font = monaco
EOF This is a release blocker for 3.5.0, first seen in 3.5.0rc1. |
We're retagging 3.5.0rc1 to fix this and one other regression. Can someone step up and get this fix checked in in the next six or eight hours? You can just check in to the 3.5 branch on hg.python.org/cpython like normal (you won't have to use Bitbucket and "pull requests" for this). |
New changeset e39c4373b83f by Ned Deily in branch '3.5': New changeset 8c55fb5a11d8 by Ned Deily in branch 'default': |
At Larry's request so that we can get 3.5.0rc1 out the door, I've checked in a temporary fix for 3.5 (and for 3.6) that should prevent the IDLE crash when linked with Tk 8.4. I'll leave the issue open for Terry to review and provide the final fix for all branches. |
I just returned from a trip. I think restoring the status quo is sufficient, so I will likely apply to 2.7 and 3.4 and null merge forward. Is there anyway to get test run with 8.4 automatically, as least intermittantly, before the rc? |
Anything happening with this? We tag 3.5.0rc3 in about 36 hours. |
New changeset 34a8078f6249 by Terry Jan Reedy in branch '2.7': New changeset b4830b9f8c10 by Terry Jan Reedy in branch '3.4': |
I backported change already in 3.5.0+. |
This change caused a regression on Linux with 8.6.4 because TkFixedFont ends up with size = 0. Cannot open configuration file. See bpo-26673. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: