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
staticMINI:String = "mini"
The font name of the embedded minimal bitmap font. Use this e.g. for debug output.
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
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.
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.
Methods
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.
getCharIDs(?result:Vector<Int>):Vector<Int>
Returns a vector containing all the character IDs that are contained in this font.