Jump to content
Sign in to follow this  
Memnarch

Issues with Fontscaling for HDPI in Delphi Berlin

Recommended Posts

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 by Memnarch

Share this post


Link to post

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×