What is the default line break size?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
a7s1h1
Prole
Posts: 12
Joined: Sat May 25, 2013 2:15 pm

What is the default line break size?

Post 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?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: What is the default line break size?

Post by bartbes »

I think [wiki]Font:getHeight[/wiki] includes this, too.
a7s1h1
Prole
Posts: 12
Joined: Sat May 25, 2013 2:15 pm

Re: What is the default line break size?

Post 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)
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: What is the default line break size?

Post 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.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: What is the default line break size?

Post 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).
a7s1h1
Prole
Posts: 12
Joined: Sat May 25, 2013 2:15 pm

Re: What is the default line break size?

Post 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!
Post Reply

Who is online

Users browsing this forum: No registered users and 59 guests