Class: TextRenderer

TextRenderer(drawContext)

Provides methods useful for displaying text. An instance of this class is attached to the WorldWindow DrawContext and is not intended to be used independently of that. Applications typically do not create instances of this class.

Constructor

new TextRenderer(drawContext)

Constructs a TextRenderer instance.
Parameters:
Name Type Description
drawContext drawContext The current draw context. Typically the same draw context that TextRenderer is attached to.
Source:
Throws:
If the specified draw context is null or undefined.
Type
ArgumentError

Members

enableOutline :boolean

Indicates if the text will feature an outline around its characters.
Type:
  • boolean
Source:

outlineColor :Color

The color for the Text outline. Its default has half transparency to avoid visual artifacts that appear while fully opaque.
Type:
Source:

outlineWidth :number

Indicates the text outline width (or thickness) in pixels.
Type:
  • number
Source:

textColor :Color

The text color.
Type:
Source:

typeFace :Font

The text size, face and other characteristics, as described in Font.
Type:
Source:

Methods

drawText(text) → {canvas2D}

Creates a 2D Canvas for a specified text string while considering current TextRenderer state in regards to outline usage and color, text color, typeface, and outline width.
Parameters:
Name Type Description
text String The text string.
Source:
Returns:
A 2D Canvas for the specified text string.
Type
canvas2D

getMaxLineHeight() → {Vec2}

Calculates maximum line height based on the current typeFace and outline usage of TextRenderer.
Source:
Returns:
A vector indicating the text's width and height, respectively, in pixels.
Type
Vec2

renderText(text) → {Texture}

Creates a texture for a specified text string and current TextRenderer state.
Parameters:
Name Type Description
text String The text string.
Source:
Returns:
A texture for the specified text string.
Type
Texture

textSize(text) → {Vec2}

Returns the width and height of a specified text string considering the current typeFace and outline usage.
Parameters:
Name Type Description
text string The text string.
Source:
Returns:
A vector indicating the text's width and height, respectively, in pixels.
Type
Vec2

wrap(text, width, height) → {String}

Wraps the text based on width and height using new line delimiter
Parameters:
Name Type Description
text String The text to wrap.
width Number The width in pixels.
height Number The height in pixels.
Source:
Returns:
The wrapped text.
Type
String

wrapLine(text, width) → {String}

Wraps a line of text based on width and height
Parameters:
Name Type Description
text String The text to wrap.
width Number The width in pixels.
Source:
Returns:
The wrapped text.
Type
String