winforms icon indicating copy to clipboard operation
winforms copied to clipboard

Form and controls are not scaled well on HDPI primary monitor when setting custom ApplicationDefaultFont

Open Olina-Zhang opened this issue 1 year ago • 3 comments

.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: image 225%DPI with .NET 9.0: image 225%DPI with .NET 8.0: image

Steps to reproduce

  1. Create a Winforms .NET 9.0 app
  2. In .csproj file, add following ApplicationDefaultFont content: <ApplicationDefaultFont>Calibri,13pt,style=regular</ApplicationDefaultFont>
  3. Open form designer, add some controls
  4. Build and run app on HDPI primary monitor

Olina-Zhang avatar Jun 28 '24 09:06 Olina-Zhang

I want to add some more details:

  1. The bug exist only with csproj + ApplicationConfiguration.Initialize();. If instead we set font in Program.cs like this: Application.SetDefaultFont(new System.Drawing.Font("Calibri", 13)); - all work fine.
  2. The bug exist only when you start app in high dpi. When start with 100% and then increase - all work fine.

kirsan31 avatar Jun 28 '24 11:06 kirsan31

@kirsan31 - thank you for the details!

merriemcgaw avatar Jun 28 '24 16:06 merriemcgaw

Issue was found when testing PR #11206

elachlan avatar Jun 30 '24 01:06 elachlan

Looks like this issue is caused by PR 10525

Epica3055 avatar Jul 04 '24 01:07 Epica3055

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 150 DPI

200% DPI Screenshot 2024-08-08 093337

Syareel-Sukeri avatar Aug 08 '24 07:08 Syareel-Sukeri

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.

John-Qiao avatar Aug 26 '24 06:08 John-Qiao

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.

John-Qiao avatar Sep 04 '24 02:09 John-Qiao