Skip to content

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Sep 18, 2017

Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are intending to get this in the upcoming releases, do what you think best as long as Appveyor passes. I will be in bed until after the cutoffs.

import tkinter.font
for name in tkinter.font.names(root):
font = tkinter.font.Font(root=root, name=name, exists=True)
font['size'] = abs(font['size'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows, this is nonsensical, but I remember that when we switched the IDLE default font to a tk default font, a year ago, there was a bug on Linux that sizes were negative. IDLE currently replaces negative sizes with 10. Should the size be negated instead?

It seems to me that the bug should be fixed in tkinter.font. Do you think that people are depending on the bug?

That aside, it is unclear how the function has any permanent effect after the function returns. I will have to trust that it does.

I would prefer that the function be put in run.py rather than a tiny new module. Pyshell already imports objects from run.py that are needed in both. If doing so results in a circular import problem, and you want to get this in before the cuttoff times today, I can fiddle with the placement and imports later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDLE currently replaces negative sizes with 10. Should the size be negated instead?

Perhaps.

It seems to me that the bug should be fixed in tkinter.font. Do you think that people are depending on the bug?

This is a delicate topic. Specifying negative size is a feature of Tk. It can be used for example for precise positioning texts together with bitmap images or other pixel graphics. And just negating it changes visible font size unless display has 72 DPI (very rarely in current days). On a display with 100 DPI a font with size 10 is 33% larger than a font with size -10.

I'll move fix_scaling to run.py.

Before merging I'm going to test changes on low-DPI display and on multi-display configuration. Would be nice to test it on OSX.


def _test():
from idlelib.editor import fixwordbreaks
from idlelib.util import fix_scaling
Copy link
Member

@terryjreedy terryjreedy Sep 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care about _test either way. It is old code that I do not use. I don't even know if it runs correctly.

@terryjreedy
Copy link
Member

terryjreedy commented Sep 19, 2017

  1. Letting the notebook size itself according to the greatest width and height of any of the pages is a good idea even without this issue.

  2. The patch cannot be auto-backported to 2.7; as there would be multiple merge conflicts. Also, the import relationship between run and PyShell is in the opposite direction. A revised patch should be tested on Linux before being submitted.

@terryjreedy
Copy link
Member

I was about to ask, how to we avoid enlarging the fonts when they should not be enlarged, as on Cheryl's system. How did you pick 1.2? On my system, with a 27" 2560 x 1440 widescreen, which I believe is not 'HiDPI', it is 1.333. In my display settings, I selected "Enlarge fonts...: 125%". I don't know if that affect tk's reported scaling factor.

How about adding and not sys.platform.beginswith('win') to the condition?

On some Linux systems, the reported size of at least TkFixedFont is 0. See bpo-26673, which changed the GetFont line 'if size < 0' to '<= 0'. Do you have any such thing on your machine? What does the following show?

try:
    import tkinter as tk
    import tkinter.messagebox
    from tkinter import font
except:
    import Tkinter as tk
    import tkFont as font

root = tk.Tk()
for name in font.names(root):
    fnt = font.Font(root=root, name=name, exists=True)
    print((name, font.Font.actual(fnt)['family'], fnt['size']))

For me:
('fixed', 'Courier New', 10)
('oemfixed', 'Terminal', 9)
('TkDefaultFont', 'Segoe UI', 9)
('TkMenuFont', 'Segoe UI', 9)
('ansifixed', 'Courier New', 10)
('systemfixed', 'Fixedsys', 9)
('TkHeadingFont', 'Segoe UI', 9)
('device', 'System', 12)
('TkTooltipFont', 'Segoe UI', 9)
('defaultgui', 'MS Shell Dlg', 8)
('TkTextFont', 'Segoe UI', 9)
('ansi', 'MS Sans Serif', 8)
('TkCaptionFont', 'Segoe UI', 9)
('system', 'System', 10)
('TkSmallCaptionFont', 'Segoe UI', 9)
('TkFixedFont', 'Courier New', 10)
('TkIconFont', 'Segoe UI', 9)
On my config dialog, 'Segoe UI' 9 is used. It is not the same as the title bar.

@terryjreedy
Copy link
Member

terryjreedy commented Sep 19, 2017

I created #3664 to immediately remove the dialog size, so I can more forward with other patches that would require it to be revised or removed. I will adjust this one once it is merged.

@terryjreedy
Copy link
Member

Merge 223caaa includes the size removal.

@csabella
Copy link
Contributor

On Ubuntu:
('TkCaptionFont', 'DejaVu Sans', -14)
('TkSmallCaptionFont', 'DejaVu Sans', -10)
('TkTooltipFont', 'DejaVu Sans', -10)
('TkFixedFont', 'DejaVu Sans Mono', -12)
('TkHeadingFont', 'DejaVu Sans', -12)
('TkMenuFont', 'DejaVu Sans', -12)
('TkIconFont', 'DejaVu Sans', -12)
('TkTextFont', 'DejaVu Sans', -12)
('TkDefaultFont', 'DejaVu Sans', -12)

@serhiy-storchaka
Copy link
Member Author

How did you pick 1.2?

This is arbitrary.

How about adding and not sys.platform.beginswith('win') to the condition?

On Windows all sizes are positive, isn't? They are not changed.

Do you have any such thing on your machine? What does the following show?

The same as @csabella.

@terryjreedy
Copy link
Member

run.py already imports sys , so it seems somewhat sensible to avoid the useless loop on windows, but this is not critical. I will presume that the current patch works fine on your machine. I decided not to worry for now about any monitors or systems that lie about the scaling. That is a bug on someone else's part.

@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the idle-fix-scaling branch September 21, 2017 08:20
terryjreedy pushed a commit to terryjreedy/cpython that referenced this pull request Sep 21, 2017
@bedevere-bot
Copy link

GH-3686 is a backport of this pull request to the 3.6 branch.

@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @serhiy-storchaka, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker a96c96f5dab68d4e611af4b8caefd7268533fd9a 2.7

csabella pushed a commit to csabella/cpython that referenced this pull request Apr 24, 2018
@bedevere-bot
Copy link

GH-6585 is a backport of this pull request to the 2.7 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants