display.newEmbossedText()

Type Function
Library display.*
Return value TextObject
Revision Release 2022.3683
Keywords embossed text, text
See also Using Custom Fonts (guide)
Display Objects (guide)
display.newText()
object:setEmbossColor()

Overview

Creates an embossed text object. The local origin is at the center of the text and the anchor point is initialized to this local origin.

Text is wrapped either at newlines or by specifying a width and height when the object is created.

By default, the text color is white ( 1, 1, 1 ). See object:setFillColor() for more information.

Syntax

display.newEmbossedText( options )

This function takes a single argument, options, which is a table that accepts the following parameters:

parent (optional)

GroupObject. Display group in which to insert the text object.

text (required)

String. The text to display. Similarly, to change the displayed text for a text object after it has been created, set the object.text property.

x / y (optional)

Numbers. Coordinates for the object's x and y center point.

width / height (optional)

Numbers. If supplied, text will be wrapped at width and cropped at height. Set height to 0 and the text box height will adjust to the amount of text, but never exceed the maximum texture height for the device.

font (required)

String, Userdata, or Constant. This can be one of the following:

fontSize (optional)

Number. The size of the text in Corona content points. The system's default font size will be used if this parameter is omitted or if it's set to nil or 0.

Important

To change the font size of a text object after it has been created, set the object.size property, not object.fontSize.

align (optional)

String. This specifies the alignment of the text when the width is known, meaning it either contains a newline or the width parameter is supplied. Default value is "left". Valid values are "left", "center", or "right".

Syntax (Legacy)

display.newEmbossedText( [parent,] text, x, y, [width, height,] font, fontSize )
parent (optional)

GroupObject. The display group to insert the embossed text object into.

text (required)

String. The text to display. Similarly, to change the displayed text for a text object after it has been created, set the object.text property.

x / y (required)

Numbers. Coordinates for the object's x and y center point.

width / height (optional)

Numbers. If supplied, text will be wrapped at width and cropped at height. Set height to 0 and the text box height will adjust to the amount of text, but never exceed the maximum texture height for the device.

font (required)

String, Userdata, or Constant. This can be one of the following:

fontSize (optional)

Number. The size of the text in Corona content points. The system's default font size will be used if this parameter is omitted or if it's set to nil or 0.

Important

To change the font size of a text object after it has been created, set the object.size property, not object.fontSize.

Gotchas

Example

local myText = display.newEmbossedText( "hello", 200, 100, native.systemFont, 40 )
myText:setFillColor( 0.5 )
myText:setText( "Hello World!" )

local color = 
{
    highlight = { r=1, g=1, b=1 },
    shadow = { r=0.3, g=0.3, b=0.3 }
}
myText:setEmbossColor( color )