Memnarch 24 Posted January 24, 2019 (edited) Hello, I'm currently working on making our application HDPI aware. We use Delphi Berlin and i encountered some strange scaling issues regarding fonts. A frame that was designed on a 96ppi Screen has a VCL Designsetting of Font.Size = 8 and Font.Height = -11. However, when the frame is created at runtime (TMyFrame.Create), it starts with a Font.Height of -21. From there on it all goes downhill. As soon as frames get parented on a control(or needs to rescale itself) that is already scaled > 96ppi, the Frame rescales its fonts(as it seems using 96ppi as a base). That means that, on a system with a scale of 200%, i get fonts the size of 400% or even 800%. The frames have "ParentFont" set. Disabling "ParentFont" at some places seems to mitigate this issue. But then again, what is happening? A TFont has a PixelsPerInch property, but that one is ignored throughout the scaling mechanics of the controls. Edited January 24, 2019 by Memnarch Share this post Link to post
Attila Kovacs 629 Posted January 24, 2019 Runtime created forms/frames (without dfm template) are not scaling in Berlin. Fixed somewhere in Tokyo/Rio. Share this post Link to post
Memnarch 24 Posted January 24, 2019 The frames do have a DFM, if that's what you mean by DFM template Share this post Link to post
Attila Kovacs 629 Posted January 24, 2019 Ah, I see. Never encounter problems on parenting a form, but for sure, HDPI is still very buggy so I'm not wondering. Just go with your workaround. 😞 Share this post Link to post
Memnarch 24 Posted January 24, 2019 ok i went overboard. Because we have a common baseframe class for all our frames, that one will now go through all its controls and fix the initial font scaling in Frame.Loaded. It is absolutely weird, that for some frames, the font has the normal -11 size and for some it is already scaled to -21. Both frames look the same in designer(regarding its font properties). So right now, i do some gueswork on which fonts to scale. Share this post Link to post
Микола Петрівський 10 Posted January 25, 2019 On 1/24/2019 at 2:52 PM, Memnarch said: Hello, I'm currently working on making our application HDPI aware. We use Delphi Berlin and i encountered some strange scaling issues regarding fonts. A frame that was designed on a 96ppi Screen has a VCL Designsetting of Font.Size = 8 and Font.Height = -11. However, when the frame is created at runtime (TMyFrame.Create), it starts with a Font.Height of -21. From there on it all goes downhill. As soon as frames get parented on a control(or needs to rescale itself) that is already scaled > 96ppi, the Frame rescales its fonts(as it seems using 96ppi as a base). That means that, on a system with a scale of 200%, i get fonts the size of 400% or even 800%. The frames have "ParentFont" set. Disabling "ParentFont" at some places seems to mitigate this issue. But then again, what is happening? A TFont has a PixelsPerInch property, but that one is ignored throughout the scaling mechanics of the controls. Yep, current HiDPI handling in VCL is far from perfect, but it has been substantially improved in Rio. I hope, they will continue moving in that direction. As for TFont.PixelsPerInch, I belive, this bug exists for more than 10 years. Fixing it will require massive changes in VCL, that is why it still exist. Share this post Link to post
Memnarch 24 Posted January 28, 2019 AH OK i got the exact situation it happens. Somestimes sfFont is not set in Scalingflags to indicate the font is already at the correct size. But the internal scaling mechanics ignore the property ScalingFlags during loadtimes and use "DefaultScaleFlags" which enforces font scaling. Checking ScalingFlags, i can now properly determine which fonts to scale back to 96ppi after dfm load. Share this post Link to post