TadvStringGrid FixedFont Sizing Bug

Hi all,

I'm struggling with getting fixedfont sizes to work right via code in TAdvStringGrids. This is hampering my ability to convert my app to use high DPI awareness and themes. I hope someone can help. I am using the TAdvString v8.5.10.0 grid component with Delphi 10.4.1 with a VCL application.

If you drop a TAdvStringgrid onto a form and keep ParentFont set to true then the grid font uses the same font as the form, but the Fixed font has to be set manually.

If you then set the fixed font to the same font and size as the form font (say 9 point) in the IDE, the grid still looks OK (same size fonts), but the Fixed font size reports in code as being 6 point.

If you then try to control font sizes in code such as like this
grid.Fixedfont.size := grid.font.size
the fixed font comes out looking larger than the standard font.

This situation seems to be true whether the form is displayed on a low or high DPI screen and whether or not the form "scaled" property is set to true or false. Have also replicated this in both 32- and 64-bit apps. My app manifest DPI awareness settings are set to "Per Monitor V2". If I set DPI awareness to "None" then the problem disappears.

I think this is a bug (presumably related to PPI settings) but perhaps I am missing something.

Thanks in advance for any assistance!

Charlie

You can set FixedFont.Size as if it is 100% DPI and for rendering the font will be scaled to adapt to the DPI of the monitor. So, it saves you from having to take DPI in account for font size setting.

Thanks Bruno, So does that mean doing something like this?
grid.Fixedfont.size := MulDiv(SizeYouWant, 96, self.CurrentPPI);

Just a quick comment though: it does seem odd that setting FixedFont works differently from setting the main grid font. Is that not a concern?

Yes it is not ideal when comparing to regular font setting.
But it is imho what the VCL should have done default, i.e. make it transparent to set font size irrespective of the DPI. So, if you want fixedfont.size = 9, you can set it this way and it should look as font size 9 regardless of DPI. We thought to make it convenient this way, but well, apparently it has pros & cons.

1 Like

Thanks!