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.