Font:WrapText

Font:WrapText

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Font:WrapText

Post by Von66341 »

Hi hi,

Anyone know how does Font:WrapText work?

I wrote this line:
FontWrapText("Please press Shift and type you current plan.",15,10,15)

but nothing was printed.

Thanks.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Font:WrapText

Post by jK »

check your syntax
wiki wrote:font:WrapText
( string "text", number max_width [, number max_height [, number size ] ])
-> nil | string wrappedText, number lines
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Font:WrapText

Post by Von66341 »

if you write it with the [] brackets it doesn't work at all.
I think they are use to explain how it works.

Any ideas? thanks.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Font:WrapText

Post by knorke »

string wrappedText
appearently the function returns the new wrapped text. with newlines \n inserted or something
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Font:WrapText

Post by Von66341 »

I tried this:

wrappedText, lineCount = myFont:WrapText("text to wrapped", 30, 30, 30 )
myFont:Print(wrappedText,x,y,fontsize,"O")

My results are:
text to ...

it doesn't seem to insert \n

Any ideas?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Font:WrapText

Post by jK »

You set the function argument max_height to 30, which obviously is only enough for 1 line. Btw you don't need to set it at all, you can leave it out or set it to nil when you need to set the fontsize argument (when fontsize isn't defined it uses the native one defined when the font was created with gl.CreateFont).
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Font:WrapText

Post by Von66341 »

Thanks lots!

I manage to get it to work =D
Post Reply

Return to “Game Development”