Open kirsan31 opened 3 years ago
@kirsan31 , you don't see this when AutoscaleMode is DPI?
@dreddy-work
you don't see this when AutoscaleMode is DPI?
Yea, with AutoscaleMode = DPI align is ok, and it's logical with 100% dpi:
In this case, i do not think winforms has any control over it. We rely on Font metrics when scaling and they come from windows. Users have alternative to set DPI scale. When it comes to high DPI, our choice should default DPI scale but that would be a breaking change from current default Font scale.
In Core, Designer is rendered as out of proc and use the targeted runtime. So, it may be worth checking the behavior there.
@dreddy-work Hmm, and if we look to this from other side? Open this project in new designer (see wrong align), correct right align, build, change dpi from 100 to 125, run app - align is wrong:
No direct font increase here, only dpi.
Also:
P.s. We relay on Font scaling instead of DPI scaling because our apps are all accessed only by rdp. And changing dpi on the server from rdp session is still challenging now days (especially with all park of different rdp clients) :( But Font scaling is work easy in this case.
Thanks @kirsan31 for the GIF demonstrating the issue. A logical fix of right aligning the label will still create same alignment issue with controls on the left. Label size is adjusted to the text in it no matter if it is DPI ( DPI change cause Font change) or Font scaled.
@dreddy-work did you got that with AutoscaleMode = DPI
issue is still present (picture after video)?
Overall I understand that to scale well right (bottom?) aligned controls we need a new technique here. Control need to know from what corner it's must be scaled.
Can I close this or we leave this for distant future? :-)
Yes. for RTL, we need special handling on the DPI changed. I have not dig into it yet but keep this bug open. We will update it with info and decide then if this need to be closed.
@dreddy-work Verified this issue in the latest .Net 7.0 SDK build, this issue doesn't reproduce now. When Right aligned controls on 100% main screen, the runtime has the same behavior as design time when changing DPI to 300% main screen. Please see following screenshot on 300% main screen:
Presume fixed. @kirsan31 please let us know if the issue resurfaces.
.NET Core Version: all up to latest tested 5.0.6
Have you experienced this same bug with .NET Framework?: No (not applicable).
Problem description:
Right aligned elements on the form can change their relative position after font scaling. For example, when you design a form in designer you often right align labels before input fields:
But after you ran this app in .Net, you will see this: Right align is broken due to Font scaling (default font change in net core).
Most interesting things, same app above: And Right align is ok.
I really don't know how this happens :) It seems that's it bugs only with 100% dpi and 100% text size. But this statement must be double checked...Seems it's all depends on the final font size.Because we are using old designer here it's seems that this is only migration issue. But this is not true, due to new designer is not ready for production use, and we are still force to use old one with .Net :(
Expected behavior:
Right align is not broken.
Minimal repro:
RightAlign.zip