Form and controls are not scaled well on HDPI primary monitor when setting custom ApplicationDefaultFont
.NET version
9.0.100-preview.7.24323.5
Did it work in .NET Framework?
Not tested/verified
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Yes, it cannot repro in .NET 8.0
Issue description
When setting custom ApplicationDefaultFont for Winforms .NET 9.0 application, added controls and form are not scaled well on HDPI primary monitor, especially the larger the DPI value, the more pronounced the results look
150%DPI with .NET 9.0:
225%DPI with .NET 9.0:
225%DPI with .NET 8.0:
Steps to reproduce
- Create a Winforms .NET 9.0 app
- In .csproj file, add following ApplicationDefaultFont content:
<ApplicationDefaultFont>Calibri,13pt,style=regular</ApplicationDefaultFont> - Open form designer, add some controls
- Build and run app on HDPI primary monitor
I want to add some more details:
- The bug exist only with
csproj + ApplicationConfiguration.Initialize();. If instead we set font inProgram.cslike this:Application.SetDefaultFont(new System.Drawing.Font("Calibri", 13));- all work fine. - The bug exist only when you start app in high dpi. When start with 100% and then increase - all work fine.
@kirsan31 - thank you for the details!
Issue was found when testing PR #11206
Looks like this issue is caused by PR 10525
Verified this issue in the latest .NET 9.0.100-rc.1.24407.33, it was fixed: Form and controls are scaled well on HDPI primary monitor when setting custom ApplicationDefaultFont. The results are the same as below.
150% DPI
200% DPI
Verified this issue with .NET 9.0.100-rc.1.24422.10 test pass build, it has been fixed and the test result is same as above.
Verified this issue with .NET 9.0.100-rc.1.24452.12 test pass build, it has been fixed and the test result is same as above.