Forum > Operating Systems

to detect the default/standard font of the OS/Widgetset

(1/5) > >>

af0815:
Is it possible to detect the standard or default font on a OS. Or which Font the user have decided to use for the apps.

Actual i have on windows 10 'ArialMT' on RasPi Jessi 'LiberationSans', on RasPi Wheezy (and Buster) 'FreeSans'. But i found no function to detect the actual system standardfont.

How can i detect this ? Because Lazarus can handle this - can somebody give me an advice where the detection in Lazarus resides.

dbannon:
Andreas, I had this problem in tomboy-ng. I found a workaround that does, sort of work for me.

KMemo always seemed to pop up with the default font but if it was changed, you needed to know what to change it back to.  So, at startup, I'd push a bit of text into the KMemo control, read its font, and then clear that text. User unaware. Can you apply this model to whatever control you are using ?

Davo

korba812:
"Screen.SystemFont" indicates default system font.

wp:

--- Quote from: af0815 on August 27, 2019, 09:31:28 am ---But i found no function to detect the actual system standardfont.

--- End quote ---
Do you really need this? Just name the font "default" like the Object Inspector does.

winni:
The Font property is a problem since years. You can write every nonsens into the Font.Name and you dont't even get an error message, that the font was not found.

Test this (just done in Linux):

The Font in Tooglebox1 is "Sans standard" which is the Linux default.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ToggleBox1.Font.Name := 'HonkDiHonk';
where 'HonkDiHonk' is pure nonsense.

No error message. Nothing changes. The font is still default.

But now it gets funny:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---showMessage (ToggleBox1.Font.Name);
And he shows you not 'default'.
And he shows you not 'Sans standard'
He shows you 'HonkDiHonk'

So even if you ask for the component.Font.Name, you might get not the right answer.


And yes, @wp: some people like design. And not only a machine for number crunshing.

Winni

Navigation

[0] Message Index

[#] Next page

Go to full version