TextBitmap Class

Extends Mesh
Module: Sprite

Text bitmap atlas with support for signed distance field data.

Input data should be composed of a BMFont file (can be a .fnt, .json. etc) file and a character atlas texture from an image.

Font atlas can be generate using the tool http:// www.angelcode.com/products/bmfont/

Based on the three-bmfont-text library.

Methods

setText

(
  • text
)

Set the text to be displayed.

Parameters:

  • text String

updateGeometry

()

Update the text bitmap geometry to match config.

Should be called every time after changes to configuration are made.

updateShader

()

Update the shader used to draw the bitmap information in the screen.

Attributes

align

String

Horizontal text alignment can be

  • TextBitmap.LEFT
  • TextBitmap.RIGHT
  • TextBitmap.CENTER

BITMAP

Number static

Simple bitmap font atlas.

CENTER

String static

Align text to the center.

color

Color

Color of the text, only applied for SDF and MSDF modes.

config

Object

BMFont text configuration object.

Passed to the BMFont text geometry generator. It is a object with the format.

{ font: (Object) Font data should be parsed from (.json, .fnt, etc) file, text: (String), width: (Number) Width of the text area, align: (String) Side to align the text, lineHeight: (Number) Line height/font size, letterSpacing: (Number) Spacing between characters, mode: (String) a mode for word-wrapper; can be 'pre' (maintain spacing), or 'nowrap' (collapse whitespace but only break on newline characters), otherwise assumes normal word-wrap behaviour (collapse whitespace, break at width or newlines) tabSize: (Number) the number of spaces to use in a single tab (default 4) start: (Number) the starting index into the text to layout (default 0) end: (Number) the ending index (exclusive) into the text to layout (default text.length) }

font

Object

BMFont text font data, contains the data about all characters available, and their position in the atlas.

Font data should be parsed from (.json, .fnt, etc) file.

Passed to the BMFont text geometry generator.

fontScale

Number

Scale applied to the generated text geometry.

LEFT

String static

Align text to the left side.

letterSpacing

Number

Spacing between each letter.

lineHeight

Number

Space between each text line.

MSDF

Number static

Multi channel signed distance field font atlas.

RIGHT

String static

Align text to the right side.

SDF

Number static

Single channel signed distance field font atlas.

shader

Number

Text bitmap rendering shader, can be:

  • TextBitmap.BITMAP
  • TextBitmap.SDF
  • TextBitmap.MSDF

smoothing

Number

Smoothing of the text borders.

text

String

Text displayed on the object.

texture

Texture

Texture containing the bitmap characters.

Data specifiyng the position of each character in the texture should be placed in the font.

threshold

Number

SDF distance alpha threshold.

uniforms

Object

Uniforms passed to the text rendering shaders.

width

Number

Width of the text box.