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
Font autoscaling doesn't function in .NET Core as it does in .NET Framework 4.8. #11214
Comments
This issue should probably be moved to dotnet/winforms. |
@swapso I believe what you're seeing is expected and by design due to the change in the default font (documented here). To ease the pain of the migration in .NET 6 we introduced Application.SetDefaultFont API and the application bootstrap (documented here, blogged here). I would also recommend reviewing the list of the breaking changes Windows Forms SDK accepted moving from .NET Framework to .NET. |
@RussKie, you're spot on. It only functions correctly when the forms are already open, as |
Difference between NET 4.8 & NET Core font scaling.pdf Hi @RussKie @Suchiman Please go through it once. |
Thank you @swapso, that's for @dotnet/dotnet-winforms team to investigate. |
This problem can be reproduced by setting a larger font size for the form and making the control layout in the Form more compact. |
@merriemcgaw @LeafShi1 @ricardobossan |
@merriemcgaw @ricardobossan @Tanya-Solyanik So the way to fix this problem
|
Description
I've just migrated a Winform project from .NET Framework 4.8 to .NET Core 9, following the porting instructions provided in the Windows documentation. However, I've encountered an issue with font autoscaling. When I adjust the font for the entire application, the controls on the form don't scale appropriately.
Reproduction Steps
Expected behavior
In a NET Core project, after changing the font, the properties of the controls like SizeX, SizeY, LocationX, and LocationY should be set to the same values as in the NET 4.8 project during events like onLoad, onShown, and FontChanged.
I have attached my application expected screenshot.
Actual behavior
In a NET Core project these properties are not getting set correctly, which ultimately causing winform UI to set weirdly.
I have attached my application actual screenshot.
Regression?
No response
Known Workarounds
Above is NET 4.8 code from System.Windows.Forms->Systems->Windows->Forms->Layout->Containers->ContainerControls.cs
and below is the same code from NET Core
Look at difference, because of base.IsHandleCreated NET Core doesn't allow to take effect of FontChanged.
if we remove that
base.IsHandleCreated
from code and test the application it works fine.Configuration
.NET version- 4.8 and .NET Core
Windows 10
x64 Architecture
Other information
No response
The text was updated successfully, but these errors were encountered: