The BitmapFont class parses bitmap font files and arranges the glyphs in the form of a text. The class parses the Xml format as it is used in the AngelCode Bitmap Font Generator or the Glyph Designer. This is what the file format looks like:

 
  <font>
    <info face="BranchingMouse" size="40" />
    <common lineHeight="40" />
    <pages>  <!-- currently, only one page is supported -->
      <page id="0" file="texture.png" />
    </pages>
    <chars>
      <char id="32" x="60" y="29" width="1" height="1" xoffset="0" yoffset="27" xadvance="8" />
      <char id="33" x="155" y="144" width="9" height="21" xoffset="0" yoffset="6" xadvance="9" />
    </chars>
    <kernings> <!-- Kerning is optional -->
      <kerning first="83" second="83" amount="-4"/>
    </kernings>
  </font>
  

Pass an instance of this class to the method registerBitmapFont of the TextField class. Then, set the fontName property of the text field to the name value of the bitmap font. This will make the text field use the bitmap font.

Static variables

@:value("mini")staticMINI:String = "mini"

The font name of the embedded minimal bitmap font. Use this e.g. for debug output.

@:value(-1)staticNATIVE_SIZE:Int = -1

Use this constant for the fontSize property of the TextField class to

 *  render the bitmap font in exactly the size it was created.

Constructor

@:value({ fontXml : null, texture : null })new(?texture:TextureMaterial, ?fontXml:Xml)

Creates a bitmap font by parsing an Xml file and uses the specified texture.

 *  If you don't pass any data, the "mini" font will be created.

Variables

baseline:Float

The baseline of the font. This property does not affect text rendering;

 *  it's just an information that may be useful for exact text placement.

read onlyfontMaterial:TextureMaterial

The underlying texture that contains all the chars.

lineHeight:Float

The height of one line in points.

read onlyname:String

The name of the font as it was parsed from the font file.

offsetX:Float

An offset that moves any generated text along the x-axis (in points).

 *  Useful to make up for incorrect font data. @default 0.

offsetY:Float

An offset that moves any generated text along the y-axis (in points).

 *  Useful to make up for incorrect font data. @default 0.

read onlysize:Float

The native size of the font.

Methods

addChar(charID:Int, bitmapChar:BitmapChar):Void

Adds a bitmap char with a certain character ID.

dispose():Void

Disposes the texture of the bitmap font!

@:value({ letterSpacing : 0, kerning : true, autoScale : true, vAlign : "center", hAlign : "center", fontSize : -1 })fillBatched(data:Vector<Float>, indices:Vector<UInt>, width:Float, height:Float, text:String, fontSize:Float = -1, hAlign:String = "center", vAlign:String = "center", autoScale:Bool = true, kerning:Bool = true, letterSpacing:Float = 0):Void

Draws text into a Geometry.

getChar(charID:Int):BitmapChar

Returns a single bitmap char with a certain character ID.

@:value({ result : null })getCharIDs(?result:Vector<Int>):Vector<Int>

Returns a vector containing all the character IDs that are contained in this font.

hasChars(text:String):Bool

Checks whether a provided string can be displayed with the font.