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 name new(text, width, align, linespace, font)
Description Create 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 name setText(text)
Description Set object with provided text
Input parameters

string text - new text to set in object

Get text

Back to method list

Method name getText()
Description Get current text

Change color

Back to method list

Method name setTextColor(color)
Description Set color for text
Input parameters

number color - color of the text in hexadecimal format.

Get color

Back to method list

Method name getColor()
Description Get current text color

Change letter spacing

Back to method list

Method name setLetterSpacing(spacing)
Description Set letter spacing for text
Input parameters

number spacing - space between letters.

Get letter spacing

Back to method list

Method name getLetterSpacing()
Description Get current letter spacing

Change alignment

Back to method list

Method name setAlignment(align)
Description Set alignment of text
Input parameters

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

Get alignment

Back to method list

Method name getAlignment()
Description Get current text alignment

Change width

Back to method list

Method name setWidth(width)
Description Set approximate width of text
Input parameters

int width - approximate width of text in pixels.

Get width

Back to method list

Method name getWidth()
Description Get current text width

Change line spacing

Back to method list

Method name setLineSpacing(spacing)
Description Set line spacing for text
Input parameters

number spacing - space between lines.

Get line spacing

Back to method list

Method name getLineSpacing()
Description Get current line spacing

Change font

Back to method list

Method name setFont(font)
Description Set font for text
Input parameters

object font - Gideros font object.

Get font

Back to method list

Method name getFont()
Description Get current font

Latest changes

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