me.Text(x, y, settings)

new Text(x, y, settings)

a generic system font object.

Parameters:
Name Type Description
x Number

position of the text object

y Number

position of the text object

settings Object

the text configuration

Properties
Name Type Attributes Default Description
font String

a CSS family font name

size Number | String

size, or size + suffix (px, em, pt)

fillStyle me.Color | String <optional>
"#000000"

a CSS color value

strokeStyle me.Color | String <optional>
"#000000"

a CSS color value

lineWidth Number <optional>
1

line width, in pixels, when drawing stroke

textAlign String <optional>
"left"

horizontal text alignment

textBaseline String <optional>
"top"

the text baseline

lineHeight Number <optional>
1.0

line spacing height

anchorPoint me.Vector2d <optional>
{x:0.0, y:0.0}

anchor point to draw the text at

text String | Array.<String> <optional>

a string, or an array of strings

Extends

Members

alpha :Number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn

Inherited From:
Default Value:
  • 1.0
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container|me.Entity

a reference to the parent object that contains this renderable

Inherited From:
Default Value:
  • undefined

fillStyle :me.Color

defines the color used to draw the font.

Default Value:
  • black

lineHeight :Number

Set the line spacing height (when displaying multi-line strings).
Current font height will be multiplied with this value to set the line height.

Default Value:
  • 1.0

lineWidth :Number

sets the current line width, in pixels, when drawing stroke

Default Value:
  • 1

strokeStyle :me.Color

defines the color used to draw the font stroke.

Default Value:
  • black

textAlign :String

Set the default text alignment (or justification),
possible values are "left", "right", and "center".

Default Value:
  • "left"

textBaseline :String

Set the text baseline (e.g. the Y-coordinate for the draw operation),
possible values are "top", "hanging, "middle, "alphabetic, "ideographic, "bottom"

Default Value:
  • "top"

Methods

static bold()

make the font bold

Returns:
-

this object for chaining

static draw(renderer, textopt, xopt, yopt)

draw a text at the specified coord

Parameters:
Name Type Attributes Description
renderer me.CanvasRenderer | me.WebGLRenderer

Reference to the destination renderer instance

text String <optional>
x Number <optional>
y Number <optional>

static drawStroke(renderer, text, x, y)

draw a stroke text at the specified coord, as defined
by the lineWidth and fillStroke properties.
Note : using drawStroke is not recommended for performance reasons

Parameters:
Name Type Description
renderer me.CanvasRenderer | me.WebGLRenderer

Reference to the destination renderer instance

text String
x Number
y Number

static italic()

make the font italic

Returns:
-

this object for chaining

static measureText(rendereropt, textopt, retopt) → {TextMetrics}

measure the given text size in pixels

Parameters:
Name Type Attributes Description
renderer me.CanvasRenderer | me.WebGLRenderer <optional>

reference a renderer instance

text String <optional>

the text to be measured

ret me.Rect <optional>

a object in which to store the text metrics

Returns:
TextMetrics -

a TextMetrics object with two properties: width and height, defining the output dimensions

static setFont(font, size)

set the font family and size

Parameters:
Name Type Description
font String

a CSS font name

size Number | String

size, or size + suffix (px, em, pt)

Returns:
-

this object for chaining

Example
font.setFont("Arial", 20);
font.setFont("Arial", "1.5em");

static setText(value)

change the text to be displayed

Parameters:
Name Type Description
value Number | String | Array.<String>

a string, or an array of strings

Returns:
-

this object for chaining