Package | starling.text |
Class | public class BitmapFont |
Inheritance | BitmapFont ![]() |
<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.
Property | Defined By | ||
---|---|---|---|
baseline : Number [read-only] The baseline of the font. | BitmapFont | ||
lineHeight : Number The height of one line in pixels. | BitmapFont | ||
name : String [read-only] The name of the font as it was parsed from the font file. | BitmapFont | ||
size : Number [read-only] The native size of the font. | BitmapFont | ||
smoothing : String The smoothing filter that is used for the texture. | BitmapFont |
Method | Defined By | ||
---|---|---|---|
BitmapFont(texture:Texture = null, fontXml:XML = null) Creates a bitmap font by parsing an XML file and uses the specified texture. | BitmapFont | ||
addChar(charID:int, bitmapChar:BitmapChar):void Adds a bitmap char with a certain character ID. | BitmapFont | ||
createSprite(width:Number, height:Number, text:String, fontSize:Number = -1, color:uint = 0xffffff, hAlign:String = center, vAlign:String = center, autoScale:Boolean = true, kerning:Boolean = true):Sprite Creates a sprite that contains a certain text, made up by one image per char. | BitmapFont | ||
dispose():void Disposes the texture of the bitmap font! | BitmapFont | ||
fillQuadBatch(quadBatch:QuadBatch, width:Number, height:Number, text:String, fontSize:Number = -1, color:uint = 0xffffff, hAlign:String = center, vAlign:String = center, autoScale:Boolean = true, kerning:Boolean = true):void Draws text into a QuadBatch. | BitmapFont | ||
getChar(charID:int):BitmapChar Returns a single bitmap char with a certain character ID. | BitmapFont |
Constant | Defined By | ||
---|---|---|---|
MINI : String = mini [static] The font name of the embedded minimal bitmap font. | BitmapFont | ||
NATIVE_SIZE : int = -1 [static] Use this constant for the fontSize property of the TextField class to
render the bitmap font in exactly the size it was created. | BitmapFont |
baseline | property |
baseline:Number
[read-only] The baseline of the font.
public function get baseline():Number
lineHeight | property |
lineHeight:Number
The height of one line in pixels.
public function get lineHeight():Number
public function set lineHeight(value:Number):void
name | property |
name:String
[read-only] The name of the font as it was parsed from the font file.
public function get name():String
size | property |
size:Number
[read-only] The native size of the font.
public function get size():Number
smoothing | property |
smoothing:String
The smoothing filter that is used for the texture.
public function get smoothing():String
public function set smoothing(value:String):void
BitmapFont | () | Constructor |
public function BitmapFont(texture:Texture = null, fontXml:XML = null)
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.
Parameterstexture:Texture (default = null )
| |
fontXml:XML (default = null )
|
addChar | () | method |
public function addChar(charID:int, bitmapChar:BitmapChar):void
Adds a bitmap char with a certain character ID.
Parameters
charID:int | |
bitmapChar:BitmapChar |
createSprite | () | method |
public function createSprite(width:Number, height:Number, text:String, fontSize:Number = -1, color:uint = 0xffffff, hAlign:String = center, vAlign:String = center, autoScale:Boolean = true, kerning:Boolean = true):Sprite
Creates a sprite that contains a certain text, made up by one image per char.
Parameters
width:Number | |
height:Number | |
text:String | |
fontSize:Number (default = -1 )
| |
color:uint (default = 0xffffff )
| |
hAlign:String (default = center )
| |
vAlign:String (default = center )
| |
autoScale:Boolean (default = true )
| |
kerning:Boolean (default = true )
|
Sprite |
dispose | () | method |
public function dispose():void
Disposes the texture of the bitmap font!
fillQuadBatch | () | method |
public function fillQuadBatch(quadBatch:QuadBatch, width:Number, height:Number, text:String, fontSize:Number = -1, color:uint = 0xffffff, hAlign:String = center, vAlign:String = center, autoScale:Boolean = true, kerning:Boolean = true):void
Draws text into a QuadBatch.
Parameters
quadBatch:QuadBatch | |
width:Number | |
height:Number | |
text:String | |
fontSize:Number (default = -1 )
| |
color:uint (default = 0xffffff )
| |
hAlign:String (default = center )
| |
vAlign:String (default = center )
| |
autoScale:Boolean (default = true )
| |
kerning:Boolean (default = true )
|
getChar | () | method |
public function getChar(charID:int):BitmapChar
Returns a single bitmap char with a certain character ID.
Parameters
charID:int |
BitmapChar |
MINI | Constant |
public static const MINI:String = mini
The font name of the embedded minimal bitmap font. Use this e.g. for debug output.
NATIVE_SIZE | Constant |
public static const NATIVE_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.