Page 1 of 1

What is the default line break size?

Posted: Mon Jun 17, 2013 11:47 am
by a7s1h1
Is there any way to find out the default distance between the lines in a wrapped text?
I'm making the text box, which size depends on the width and the number of lines of the text.
In order to calculate the required height of the box, I use the following formula:
Number_of_lines*Font_size+(Number_of_lines-1)*line_break_size+Margins

I know the number of lines due to Font:getWrap, I certainly know the font size I'm using and I set the 10px margins from each side.
But what is the line break size?

Re: What is the default line break size?

Posted: Mon Jun 17, 2013 12:03 pm
by bartbes
I think [wiki]Font:getHeight[/wiki] includes this, too.

Re: What is the default line break size?

Posted: Mon Jun 17, 2013 12:59 pm
by a7s1h1
bartbes wrote:I think [wiki]Font:getHeight[/wiki] includes this, too.
Nope, unfortunately. Whenever I have 1 or two lines the height is still 14 (with 12 size font)

Re: What is the default line break size?

Posted: Mon Jun 17, 2013 1:02 pm
by raidho36
Probably that's because this is font's height, not rendered text one's. If you know exactly how many rows you have, multiply it by font height.

Re: What is the default line break size?

Posted: Mon Jun 17, 2013 1:06 pm
by raidho36
Oh, I got it. You can obtain your height as following:

Code: Select all

local height = yourfont:getHeight * yourfont:getWrap ( textstring ) 
That should do the trick.

Wasn't meant to doublepost, but current member group won't let me edit my posts (or even see them for that matter).

Re: What is the default line break size?

Posted: Mon Jun 17, 2013 1:07 pm
by a7s1h1
Seems that I've found the answer. I just had to multiply the Font:getHeight by the number of lines. Thus 14*1=14, 14*2=28 etc. So, I guess, the margin of each of the line is 1px from each side.
Anyway, thats enough to make the text box borders depend on the text block size properly.
Thanks for the help!