Set Font.Size in FormCreate cause scaled twice
Original Reporter info from Mantis: baldzhang @baldzhang
-
Reporter name: bald zhang
Original Reporter info from Mantis: baldzhang @baldzhang
- Reporter name: bald zhang
Description:
migration an exist project to 1.7
set DPI awareness to "on" in project options, nothing changed with unit/forms
when program execute on a 4k display(192dpi), the font was double sized to 18.
existing code has
Font.Size := 9;
in FormCreate
do some tracking, the problem is
1) in TFont.SetFont
FHeight := -MulDiv(AValue, FPixelsPerInch, 72);
where FPixesPerInch is 192
then FHeight = -24
2) in TCustomForm.DoAutoAdjustLayout
Form's DesignTimePPI = 192, read from Screen, and PixelsPerInch = 96, the default value
then another round of scaled performed, Font.Size changed to 18.
I try to do like this:
Font.Height := 12; (simulate calculation: 9 * 96 / 72)
then the program looks ok.
as far as I know, lots of code was written like "Font.Size := ##", then this may confuse lots of people...