Forum > Operating Systems

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

<< < (2/5) > >>

sstvmaster:
Something like this?


--- 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";}};} ---function GetDefaultFontSize: integer;var  fd: TFontData;begin  fd := GetFontData( Form1.Font.Handle );  result := round((fd.Height * 72 / Form1.Font.PixelsPerInch) * (-1));end; procedure TForm1.FormCreate(Sender: TObject);begin  // set font name to nonsense  Form1.Font.name := 'GoodMorningStarshine';  Label1.Caption := 'Default font name : ' + GetFontData(Self.Font.Handle).Name;  Label2.Caption := 'Default font size : ' + IntToStr(GetDefaultFontSize);   // get and set system font name/size  Form1.Font.Name := Screen.SystemFont.Name; // only to be shure  Form1.Font.SetDefault; // <-- important !!!  Label3.Caption := 'System font name : ' + Screen.SystemFont.Name;  Label4.Caption := 'System font size : ' + IntToStr(Screen.SystemFont.Size); end;

winni:
Yes, that is the way it is normaly done.


But insert in your Formcreate as first line the following:


--- 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";}};} ---Form1.Font.name := 'GoodMorningStarshine'; 
And suddenly you don't know nothing!

Winni

sstvmaster:
And why i should do this? If you override the font name with nonsense, you get nonsense.

I have updated the code in my post please try.

winni:
Yeah, that's what I wanted to show.

Everywhere the compiler or the RTL tries to keep you away from nonsense, but not in this case.

Think about those scenarios:

*In the Formcreate you make a typo inside the string Font.Name: The compiler will not detect it and the RTL - as shown - doesn't care about your nonsens. No error message is given.

* Your program starts on a computer, where the desired font is not installed. As above: No errors detected and no message given.

That was what I wanted to show.

Winni

af0815:
The Problem i have, is on different RasPi versions the fonts differs and i have a report without bindings to the lcl. So i have to say the reportengine the correct font and size. And this font must available. This must also be done if i use a lcl renderer.

Now i have some Parts to deal with. Thanks

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version