question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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. Snipaste_2020-05-04_11-46-25 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. Snipaste_2020-05-04_11-35-08

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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
kirsan31commented, Nov 25, 2021

@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: image

net6.0-windows targets will fail to build with dozen’s of import errors: image image

These targets, still builds fine: net7.0-windows;net5.0-windows;netcoreapp3.1;net472

2reactions
merriemcgawcommented, May 9, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix DPI display issues in Windows Form Designer - Visual ...
In the Options dialog, choose Windows Forms Designer > General, and set DPI Scaling Notifications to False. Troubleshoot. If the DPI-awareness ...
Read more >
c# - Windows Forms DPI scaling
My application looks good with 100% DPI setting, but when user selects different (125% or 150%) words don't fit in containers. I tried...
Read more >
Distorted appearance in Design Mode running on scaled ...
When scaling is enabled on a high-resolution setup, this can cause display issues with some forms in the Design, like: SmartTag button is...
Read more >
High DPI Support in Windows Forms Controls
The DPI scaling mechanism calculates the scaling difference between the system that form has been designed on and the running system. This DPI...
Read more >
Font size is too big on Windows 10 for some applications
I can fix this on a per-application basis by changing the "high DPI settings" under the Context Menu>Properties>Compatibility tab for the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found