DPI scaling is broken if font of the form set in designer
See original GitHub issue-
.NET Core Version: 3.1.3
-
Have you experienced this same bug with .NET Framework?: Yes
Problem description:
DPI scaling (AutoScaleMode.Font) is broken if font of the form set in designer. Or you can read it as: DPI scaling is broken if font of the form set after DPI scaling logic code, even in SuspendLayout and before very first PerformLayout.
If you put yellow code in front of pink, or in constructor before InitializeComponent(); - all will be ok.
The bug appear only if this font is different from current system font.
Win10 pro 1809/1909.

Related old stackoverflow post.
My personal opinion is that this is not designer problem, this is the problem of DPI scaling logic that depends on instructions order even in SuspendLayout…
Expected behavior: Form must be scaled correctly.
Minimal repro: This test project was created in VS 16.6 preview 5 with using of new core designer: WindowsFormsAppDesignerDPI.zip
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:13 (13 by maintainers)

Top Related StackOverflow Question
@RussKie @dreddy-work Just checked it with latest .Net7 sdk and it’s defiantly fixed! Time to port this fix to .Net6 (#6151) 😃
P.s. after installing .Net7 sdk and enabling this in VS2022:
net6.0-windowstargets will fail to build with dozen’s of import errors:These targets, still builds fine:
net7.0-windows;net5.0-windows;netcoreapp3.1;net472…We’re working on our longer term roadmap in the coming weeks. I’m starting to see more and more requests for a DPI overhaul from multiple channels, so I’m certain it will be one of the next big things once we get the designer work completed.