-
Notifications
You must be signed in to change notification settings - Fork 997
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
Fix 11214 by adding a default font check before executing PerformAutoScale #11641
base: main
Are you sure you want to change the base?
Fix 11214 by adding a default font check before executing PerformAutoScale #11641
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11641 +/- ##
===================================================
+ Coverage 74.51776% 75.06831% +0.55055%
===================================================
Files 3040 3059 +19
Lines 629560 632003 +2443
Branches 46839 46782 -57
===================================================
+ Hits 469134 474434 +5300
+ Misses 157058 154190 -2868
- Partials 3368 3379 +11
Flags with carried forward coverage won't be shown. Click here to find out more. |
I'm not sure that this fix addresses all possible cases. Fundamentally, we are missing information about what font/DPI the controls are scaled for right now. This fix assumes that the application was designed for the DefaultFont and that the current sizes are still set to the "initial" sizes. The former assumption is reasonable, the latter is not necessarily true. Maybe the application had been resized a couple of times and the current sizes are not appropriate for the default font anymore. Previous layout design relied on the AutoScaling ratios to maintain the current state as related to the original designed sizes. We would need to either revive that logic or to implement an extention on it. I suggest we revisit this bug in NET10 |
@LeafShi1 - let's revisit this change in NET10 |
@Tanya-Solyanik According to customer feedback, this fix can solve their problem. I tried to change the font several times, setting three different fonts in Form.cs and Form.Designer.cs, and the scaling results were normal. But there is a question, should we scale the font before the handle is created? |
We don't have this information at the Handle creation time. In some cases the requested size will be already scaled by the user app and in some it would be the default size. We have |
Whether the form/control automatically scales should not be linked to the handle I did the following experiment
So whether the form automatically scales should not be linked to the handle. What do you think? |
I'm concerned about scaling for the DPI. At the runtime, the form should be scaled according to the DPI of the screen it's created on from the DPI it was designed on. I.e. if the design time DPI scaling is 100%, but the runtime DPI scaling is 200%, form size should be doubled. If the Form uses AutoScaleMode.Dpi, then font should be rescaled. However, we don't always know what on what screen the control is displayed and we might have to scale font after handle is created, when we know the current screen DPI. And we don't know if the default font had been scaled. It is more efficient to scale the default font and have it applied to all controls in the application than to scale font on each container control. Jeremy is planning to rework the default font handling. So fix for this issue will depend on the new infrastructure that he will put in. Could you please wait with this this change until that work is done? |
OK, I will wait for the new infrastructure |
Redoing layout is not something we're going to get to for a while. We should look at a targeted fix for .NET 10 here, even if it is behind a compat switch. |
Do you mean add an AppContext switch for it? |
Fixes #11214
Proposed changes
-Add a check on the default font setting in the OnFontChanged function of ContainerControls.cs to ensure that PerformAutoScale is executed smoothly
Customer Impact
Risk
Screenshots
Before
When I adjust the font for the entire application, the controls on the form don't scale appropriately
After
The controls on the form can be scaled appropriately after adjust the font for the entire application
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow