Core. BitmapFont

BitmapFont Is a bitmap font class used to define bitmap font information. Fonts and methods of use, please refer to the article

Constructor

new BitmapFont()

See:

Member

autoScaleSize :Boolean

Indicates whether to scale the bitmap font size according to the actual font size used.

fontSize :Number

The current bitmap font font size, when used, if the font size and settings are different, and autoScaleSize=true, then according to the set font ratio scaling display.
Default Value:
  • 12

letterSpacing :Number

Character spacing (in pixels).
Default Value:
  • 0

Methods

destroy()

Destroy bitmap fonts and destroy them by default when calling Text.unregisterBitmapFont.

getCharTexture(char) → {Texture}

Gets the font texture object for the specified character.
Parameters:
Name Type Description
char String Character.
Returns:
Type:
Texture
Specifies the font texture object.

getCharWidth(char) → {Number}

Gets the width of the specified character.
Parameters:
Name Type Description
char String Character.
Returns:
Type:
Number
Width.

getMaxHeight()

Get maximum character height.

getMaxWidth()

Get maximum character width.

getTextWidth(text) → {Number}

Gets the width of the specified text content.
Parameters:
Name Type Description
text String Text content.
Returns:
Type:
Number
Width.

loadFont(path, complete)

By specifying the bitmap font file path, the bitmap font file is loaded and automatically parsed after the load is complete.
Parameters:
Name Type Description
path String The path to the bitmap font file.
complete Handler Load and parse the completed callback.

parseFont(xml, texture)

Parse font file.
Parameters:
Name Type Description
xml XmlDom Font file XML.
texture Texture Font texture.

setSpaceWidth(spaceWidth)

Set the width of the space (if the font library has spaces, it can be set aside).
Parameters:
Name Type Description
spaceWidth Number The width is in pixels.