BitmapFont
The BitmapFont object parses bitmap font files and arranges the glyphs
in the form of a text.
The object parses the Xml format as it is used in the <http://www.angelcode.com/products/bmfont/>AngelCode Bitmap Font Generator or the <http://glyphdesigner.71squared.com/>Glyph Designer.
This is what the file format looks like:
<pre>
<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>
</pre>
Pass an instance of this object to the method registerBitmapFont of the TextField object. 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.
BitmapFont object can be created using method new:
Lib.Away3D.Text.BitmapFont.new(texture, fontXml) |
Creates a bitmap font by parsing an Xml file and uses the specified texture. If you pass nil data, the "mini" font will be created. |
texture - (TextureMaterial) default nil fromXml - (Xml) default nil |
BitmapFont has static constants:
Lib.Away3D.Text.BitmapFont.NATIVE_SIZE |
Use this constant for the fontSize property of the TextField object to render the bitmap font in exactly the size it was created. |
Lib.Away3D.Text.BitmapFont.MINI |
The font name of the embedded minimal bitmap font. Use this e.g. for debug output. |
Created BitmapFont object has properties:
name |
[read-only] The name of the font as it was parsed from the font file. |
size |
[read-only] The native size of the font. |
lineHeight |
The height of one line in points. |
baseline |
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 |
An offset that moves any generated text along the x-axis (in points). Useful to make up for incorrect font data. default 0. |
offsetY |
An offset that moves any generated text along the y-axis (in points). Useful to make up for incorrect font data. default 0. |
fontMaterial |
[read-only] The underlying texture that contains all the chars. |
methods:
dispose() |
Disposes the texture of the bitmap font |
|
getChar(charID) |
Returns a single bitmap char with a certain character ID. Returnes (BitmapChar) object. |
charID - character ID. Int |
addChar(charID, bitmapChar) |
Adds a bitmap char with a certain character ID. |
charID - character ID. Int bitmapChar - (BitmapChar) |
getCharIDs(result) |
Returns a vector array containing all the character IDs that are contained in this font. |
result - pass result to this Vector array of Int (default nil) |
hasChars(text) |
Checks whether a provided string can be displayed with the font. Returnes Boolean. |
text - String |
fillBatched(data, indices, width, height, text, fontSize, hAlign, vAlign, autoScale, kerning, letterSpacing) |
Draws text into a Geometry. |
data - Vector array of Float indices - Vector array of Int width - Float height - Float text - String fontSize - Float (default -1) hAlign - (HAlign) (default CENTER) vAlign - (VAlign) (default CENTER) autoScale - Boolean (default true) kerning - Boolean (default true) letterSpacing - letter spacing. Float (default 0) |
getMaterialClone() |
Returnes (TextureMaterial) |
|
Created with the Personal Edition of HelpNDoc: Benefits of a Help Authoring Tool