New submission from E. Paine <paineeli...@gmail.com>:

Following #33656, IDLE now "lies" to Windows and declares it has system DPI 
awareness to achieve a *sharper* look. System dpi is in effect:
DPI_AWARENESS_UNAWARE * Windows' zoom factor

Therefore, for IDLE to scale to the Windows' zoom/scale factor (System > 
Display > Scale and layout > Change the size of text, apps and other items), we 
need multiply the user's chosen font size by the zoom factor.

Unfortunately I cannot quote the docs about the multiplication I gave above but 
have extensively tested and found this to hold true (the docs are not very 
explanatory but a link and small snippet can be found below):

DPI_AWARENESS                Return value
DPI_AWARENESS_UNAWARE        96
DPI_AWARENESS_SYSTEM_AWARE   The system DPI.
[https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow]

We can use the GetDpiForWindow function to get the system dpi and divide it by 
96 (DPI_AWARENESS_UNAWARE) to get the scale factor for the font. This keeps 
IDLE sharp while allowing it to respect the user's scaling preferences.

I was not intending for this to not be an option (it would happen on any 
Windows system unless the user digs through the source), though appreciate that 
it could cause a significant change on first-load.

I considered adding this logic to the idlelib.run.fix_scaling method (which 
already modifies tkinter font size) but thought that users would not want this 
if their application was not set as DPI aware so settled on extending the 
idlelib.config.IdleConf.GetFont method instead.

My motivation for this is that currently that the user has to manually change 
their font size to match their Windows zoom factor (IDLE, without the user 
changing their font size, remains the same size regardless of what setting the 
user chooses as their scale factor). I have prepared a branch if this change is 
something that would interest you Terry.

Eryk, I have nosied you as I believe you are the person for Windows API calls 
(please do remove yourself if I am wrong).

----------
assignee: terry.reedy
components: IDLE
messages: 376733
nosy: epaine, eryksun, taleinat, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE: scale font to Windows' "zoom" factor
type: enhancement
versions: Python 3.10, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41763>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to