Gideros TextWrap object splits string into multiple lines by provided width.

You can also specify line spacing and alignment modes : left, right, center and justify. And it is completely compatible with existing TextField object methods

Package contains TextWrap.lua and example Gideros application project.

Contents

Download

Example codes

--limiting text by aproximately 250px
local text = TextWrap.new("String to limit and split in lines", 250, "justify")
text:setLineSpacing(5)
text:setPosition(10,10)
text:setTextColor(0xff0000)
stage:addChild(text)

Example video

Video of module example app:

Method list

Constructor

Back to method list

Method namenew(text, width, align, linespace, font)
DescriptionCreate TextWrap object with specified configurations
Input parameters

string text - text to split to lines and display

int width - width to approximately limit string (precision not guaranteed)

string align - Alignment of text, values: left, right, center, justify (default: left)

int linespace - space in pixels between lines (default: 2)

object font - Gideros font object (default: nil)

Example input
TextWrap.new("String to limit and split in lines", 250, "justify")

Change text

Back to method list

Method namesetText(text)
DescriptionSet object with provided text
Input parameters

string text - new text to set in object

Get text

Back to method list

Method namegetText()
DescriptionGet current text

Change color

Back to method list

Method namesetTextColor(color)
DescriptionSet color for text
Input parameters

number color - color of the text in hexadecimal format.

Get color

Back to method list

Method namegetColor()
DescriptionGet current text color

Change letter spacing

Back to method list

Method namesetLetterSpacing(spacing)
DescriptionSet letter spacing for text
Input parameters

number spacing - space between letters.

Get letter spacing

Back to method list

Method namegetLetterSpacing()
DescriptionGet current letter spacing

Change alignment

Back to method list

Method namesetAlignment(align)
DescriptionSet alignment of text
Input parameters

string align - text alignment, possible values: left, right, center, justify.

Get alignment

Back to method list

Method namegetAlignment()
DescriptionGet current text alignment

Change width

Back to method list

Method namesetWidth(width)
DescriptionSet approximate width of text
Input parameters

int width - approximate width of text in pixels.

Get width

Back to method list

Method namegetWidth()
DescriptionGet current text width

Change line spacing

Back to method list

Method namesetLineSpacing(spacing)
DescriptionSet line spacing for text
Input parameters

number spacing - space between lines.

Get line spacing

Back to method list

Method namegetLineSpacing()
DescriptionGet current line spacing

Change font

Back to method list

Method namesetFont(font)
DescriptionSet font for text
Input parameters

object font - Gideros font object.

Get font

Back to method list

Method namegetFont()
DescriptionGet current font

Latest changes

  • 13. March 2012 - support for new line symbol added