Auto scale explicitly specified font as per the Settings display text scale. - #6580
Auto scale explicitly specified font as per the Settings display text scale.#6580kirsan31 wants to merge 1 commit into
Conversation
…he Settings display text scale settings.
338bd89 to
3c86d7b
Compare
|
@dreddy-work can you briefly look into this? Dose it fit with your understanding of HDPI in WinForms and https://github.com/dotnet/winforms/projects/4? |
|
@kirsan31, thank you for bringing this up. We eventually looking to add this support in WinForms. We haven't discussed this feature in length yet so, cannot comment on the supported modes or if we go with just one state here (either scale or don't). But this proposal helps in right direction. Majority of this work involves validating on various combinations of the application scaling. I should be able to take a deeper look next week. Meanwhile, can you explore following combinations with your prototype to capture possible challenges?
Also, wherever possible, please add gif of the operation instead of screenshot, that helps understand complete context of the issue being reported. |
|
@dreddy-work thanks for the response!
All of my tests was with
Already done in test app above - present on screenshot. All explicitly specified fonts are specially made different from the system - italic or bold, controls with system font are marked with text:
Wow didn't even think about that - will have to check...
I always trying to record a video for issue/repro. But in this case ( |
I agree the PMv2 is not complete but that shouldn't block to find if bug is a result of this change. We can compare with base (before changes) here.
One thing to include here ( if not already) is
Sure. It was a reminder only when you find an interesting issue to report. If everything as expected, screenshots are good enough. |
|
@dreddy-work I have updated 1 post with new testing app and testing results. With |
On the fly Dpi (changing Dpi while app is running) may need OS support (to raise Dpi changed messages). I would focus on PermonV2 mode excluding on the fly Dpi change for now. |
|
Btw, i am curious what is going wrong in your prototype. please share/post the gif. :) (We can always edit and remove if become irrelevant) |
All of them already in 1 post, under CLICK ME button. PermonV2 in the last video. --- UPD --- I spent some time on PermonitorV2 behavior and ran into a lot of problems...
PMV2_fb.mp4
DPI scaling only - fonts not increasing at all: Font scaling only - fonts increasing by 1.25: DPI scaling + Font scaling - fonts increasing by more then 1.25: 2.1 Then I decided to check how the default app font is scaled (should be exactly the same). And I couldn't turn it on (.Net6 / .Net7) 🤔 : [STAThread]
static void Main()
{
Application.SetDefaultFont(new Font(Control.DefaultFont.FontFamily, 7, FontStyle.Bold));
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
} [STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
Application.SetDefaultFont(new Font(Control.DefaultFont.FontFamily, 7, FontStyle.Bold));
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}no effect :( |
@kirsan31 Thank you for continuing on this. In this gif, i see you changed Font and i see Font on the label changed except Default Font. I did not get fully on what exactly going wrong here vs expectations. Can you demonstrate issue within the app layout ( not cached values in source) and how is this different in various DPI modes here? |
This is how Winforms designed. When set DPI mode, Font change won't affect unless control itself is a common control and depend on Font( ex: Label). For this exercise, lets just focus on the Font mode ( and make sure we don't regress in DPI modes). DPI mode, we can open discussion on separate thread. |
The problem with new functionality + PermonitorV2 demonstrated in the last video of the 1 post. And in this video I show the main reason for it - font change to something undesired after DPI switch. Then we switch DPI to 100% and both fonts became 7 size 😮 :
Apparently I confused you - sorry. All screens in my previous post with |
|
@kirsan31, Sorry for the delayed response. I will go over this again this week and try to bring this to internal review soon. |
|
@kirsan31, thank you so much getting this prototype so far. We discussed this proposal internally and conceptually agreed on it. Given the complexity involved at runtime layout and its impact on the designer serialization (design-time), we would want to wait on this until we add DPI scaling support fully to winforms runtime. We also have a Proposal about serializing the layout info ( i.e size , width etc) in logical units ( 100% DPI) that may also be impacted by this. |
I want to add some clarification here - this PR have NO impacts on designer (besides some new properties). Initial goal is - font scale controls with explicitly font set. The problem is that currently runtime scale control only if it use system font (no font was manually set). Can be solved with 2 approach:
|
@kirsan31, we are reacting to the property value here and changing the Font value at runtime. I believe it impacts the serialization of the designer. You can try following to confirm.
|
Indeed, I didn't think of that scenario... 😟 |
|
The current status of this "draft" PR has persisted for over 180 days, making it highly probable that it is no longer aligned with the latest codebase. Our repository is set up to automatically close draft PRs that have become outdated, and it requests the author to revisit and reopen them if they deem it necessary, thereby bringing them to the team's attention. |







This is a draft implementation of auto scaling explicitly specified control font as per the Settings display text scale. As already done with app default font.
Fixes #3263 implicitly.
Proposed changes
FontAutoScale:FontAutoScaletoControlclass:ExplicitFonttoControlclass. Not required, but probably desirable:Customer Impact
Customers will be able to use custom fonts without losing the ability to scale using the system font:

Regression?
Risk
Screenshots
CLICK ME
Before (150% text size)
.Net6SystemAwareandAutoScaleMode.FontAfter (150% text size)
All explicitly specified fonts are specially made different from the system - italic or bold, controls with system font are marked with text:

system font. AllFontAutoScalemodes also displayed on controls..Net7SystemAwareandAutoScaleMode.FontBefore / After gif (125% text size)
.Net7SystemAwareandAutoScaleMode.Font.Net7SystemAwareandAutoScaleMode.DpiBefore / After video (125% text size and DPI 125 -> 100%)
.Net7PerMonitorV2andAutoScaleMode.Font- all work fine until we switch DPI on the fly (and than changeFontAutoScale) - need to investigate...PMV2.mp4
Test methodology
Manual. Testing app (with binary's for simplicity):
FontScale.zip
To do.
Accessibility testing
Not necessary - correct me if I'm wrong.
To do
PerMonitorV2- everything breaks after we switch DPI on the fly - need to investigate...DataGridView,ListView... Without additional implementation in each of them, scaling will work only if one font is specified for the entire control.Microsoft Reviewers: Open in CodeFlow