Recent

Author Topic: [Solved] Making LCL applications honour Windows "Font size" setting  (Read 864 times)

lighterowl

  • Newbie
  • Posts: 2
tl;dr LCL applications don't seem to support "Font size" (not related to desktop/screen scaling) out-of-the-box, yet Lazarus IDE does - what API call/setting am I missing?

Hi everyone.
I'm trying to add support for "Font size" to my application. Keep in mind that this setting is separate to any scaling settings which are applied in "Display settings". The one I'm talking about can be found in the "Accessibility" (Windows 11) or "Ease of Access" (Windows 10) sections in "Settings". The first attachment shows what the setting looks like under Windows 11.

I recreated the application used in https://wiki.lazarus.freepascal.org/High_DPI for illustration purposes. LCL scaling in "Project Settings" is checked, "Application.Scaled := True" is generated in .lpr, and "DPI awareness" is set to "on (True)" - these settings are the defaults and the same settings are also used in Lazarus IDE itself (at least according to https://gitlab.com/freepascal.org/lazarus/lazarus/-/blob/main/ide/lazarus.lpi).

What I found out is that :
  • Form.Font.Size = 0 makes LCL respect "Font size", but the rest of the form is broken. However Form.Font.Size = 0 means that scaling won't work - at least according to https://wiki.lazarus.freepascal.org/High_DPI - so this isn't really acceptable for me anyway.
  • Form.Font.Size = 9 makes scaling work, but "Font size" is not respected anymore, even when scaling is set to something else than the default 100 as the size of the font in the rendered form is the same regardless of the setting.

The second attachment shows a summary of the combinations I've tried.

Last but not least, the last attachment shows the Lazarus IDE when running with "Font size" set to 150% (or 125%, I can't remember now) - as you can see, the fonts are indeed larger. I'd love to find what it is that Lazarus IDE is doing to achieve that but I really don't even know what I'm looking for.

Thanks.
« Last Edit: September 25, 2024, 07:08:30 pm by lighterowl »

tetrastes

  • Hero Member
  • *****
  • Posts: 694
Re: Making LCL applications honour Windows "Font size" setting
« Reply #1 on: September 25, 2024, 04:10:10 pm »
  • Form.Font.Size = 0 makes LCL respect "Font size", but the rest of the form is broken. However Form.Font.Size = 0 means that scaling won't work - at least according to https://wiki.lazarus.freepascal.org/High_DPI - so this isn't really acceptable for me anyway.

That's wrong. The scaling works in this case, but you didn't try it, at least there is no this case in your pic.

lighterowl

  • Newbie
  • Posts: 2
Re: Making LCL applications honour Windows "Font size" setting
« Reply #2 on: September 25, 2024, 07:08:14 pm »
  • Form.Font.Size = 0 makes LCL respect "Font size", but the rest of the form is broken. However Form.Font.Size = 0 means that scaling won't work - at least according to https://wiki.lazarus.freepascal.org/High_DPI - so this isn't really acceptable for me anyway.

That's wrong. The scaling works in this case, but you didn't try it, at least there is no this case in your pic.
Thank you. I must have misunderstood what the Wiki is saying, as to me the takeaway was "use fixed fonts or else" - which is why I didn't even bother to test that combination.
Setting form font sizes to 0 makes both scaling and "Font Size" work properly, so this is resolved as far as I'm aware.

 

TinyPortal © 2005-2018