Forum > LCL

TEdit height vs font size

(1/3) > >>

Kaller:
How does the height of a TEdit relate to the font height? Is it predictable?

dbannon:
Seems to for me, is your experience otherwise ?  Here is '40' and '6' respectively.
Davo

AlexTP:
Poster means 'what is the formula to get the height from the font.size?'

dbannon:
Well, in case the OP does want to know what the relationship is ....

1. Use the source Luke !   
2. Remember, each OS will be different, these controls are drawn by the local systems, not Lazarus.
3. Do some tests -

--- 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";}};} ---procedure TForm1.Button1Click(Sender: TObject);begin    Edit1.Font.Height := Edit1.Font.Height + 10;    Memo1.Append('Font Height = ' + inttostr(Edit1.Font.Height) + ' and ctrl height = ' + inttostr(Edit1.Height));end;     

Gives me, on Linux using Mate Desktop, today -


--- Code: ---Font Height = 10 and ctrl height = 21
Font Height = 20 and ctrl height = 32
Font Height = 30 and ctrl height = 44
Font Height = 40 and ctrl height = 55
Font Height = 50 and ctrl height = 66
Font Height = 60 and ctrl height = 77
Font Height = 70 and ctrl height = 88
Font Height = 80 and ctrl height = 100
Font Height = 90 and ctrl height = 111
Font Height = 100 and ctrl height = 122
--- End code ---

If you are only programming for one OS, my might be happy with the rule of thumb that data indicates but I most certainly would not trust it !  You will have to look at the source. Not a great answer. I won't send you a performance review .....

Davo

rvk:
Have you looked at the wiki?
https://wiki.lazarus.freepascal.org/Font

The documentation is indeed severly lacking
https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/tfont.height.html

For Windows you can also look at the documentation of Delphi.


--- Quote ---Font.Height = -Font.Size * Font.PixelsPerInch / 72
--- End quote ---

Note that Height can be negative.

--- Quote ---Use Height to specify the height of the font in pixels. If the value is negative, the internal leading that appears at the top of each line of text is not measured. If the value is positive, Height represents the height of the characters plus the internal leading.
--- End quote ---
https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.Graphics.TFont.Height

Navigation

[0] Message Index

[#] Next page

Go to full version