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.

### Hierarchy

- BitmapFont

### Implements

- ITextCompositor

## Index

### Constructors

- constructor

### Properties

- baseline
- distanceFieldSpread
- lineHeight
- name
- offsetX
- offsetY
- padding
- size
- smoothing
- type
- MINI
- NATIVE_SIZE

### Methods

- addChar
- arrangeChars
- clearMeshBatch
- createSprite
- dispose
- fillMeshBatch
- getChar
- getCharIDs
- getDefaultMeshStyle
- get_baseline
- get_distanceFieldSpread
- get_lineHeight
- get_name
- get_offsetX
- get_offsetY
- get_padding
- get_size
- get_smoothing
- get_texture
- get_type
- hasChars
- set_baseline
- set_distanceFieldSpread
- set_lineHeight
- set_offsetX
- set_offsetY
- set_padding
- set_smoothing
- set_type

## Constructors

### constructor

- new BitmapFont(texture?: Texture, fontData?: any): BitmapFont

- - Defined in lib/starling/text/BitmapFont.d.ts:56

  Creates a bitmap font from the given texture and font data. If you don't pass any data, the "mini" font will be created.

  #### Parameters

  - ##### Optional texture: Texture

    The texture containing all the glyphs.

  - ##### Optional fontData: any

    Typically an XML file in the standard AngelCode format. override the the 'parseFontData' method to add support for additional formats.

  #### Returns BitmapFont

## Properties

### baseline

baseline: number

- Defined in lib/starling/text/BitmapFont.d.ts:139

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.

### distanceFieldSpread

distanceFieldSpread: number

- Defined in lib/starling/text/BitmapFont.d.ts:123

If the font uses a distance field texture, this property returns its spread (i.e. the width of the blurred edge in points).

### lineHeight

lineHeight: number

- Defined in lib/starling/text/BitmapFont.d.ts:128

The height of one line in points.

### name

name: string

- Defined in lib/starling/text/BitmapFont.d.ts:109

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

### offsetX

offsetX: number

- Defined in lib/starling/text/BitmapFont.d.ts:145

An offset that moves any generated text along the x-axis (in points). Useful to make up for incorrect font data. @default 0.

### offsetY

offsetY: number

- Defined in lib/starling/text/BitmapFont.d.ts:151

An offset that moves any generated text along the y-axis (in points). Useful to make up for incorrect font data. @default 0.

### padding

padding: number

- Defined in lib/starling/text/BitmapFont.d.ts:158

The width of a "gutter" around the composed text area, in points. This can be used to bring the output more in line with standard TrueType rendering: Flash always draws them with 2 pixels of padding. @default 0.0

### size

size: number

- Defined in lib/starling/text/BitmapFont.d.ts:113

The native size of the font.

### smoothing

smoothing: string

- Defined in lib/starling/text/BitmapFont.d.ts:133

The smoothing filter that is used for the texture.

### type

type: string

- Defined in lib/starling/text/BitmapFont.d.ts:117

The type of the bitmap font. @see starling.text.BitmapFontType @default standard

### Static MINI

MINI: string

- Defined in lib/starling/text/BitmapFont.d.ts:56

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

### Static NATIVE_SIZE

NATIVE_SIZE: number

- Defined in lib/starling/text/BitmapFont.d.ts:53

Use this constant for the `fontSize` property of the TextField class to render the bitmap font in exactly the size it was created.

## Methods

### addChar

- addChar(charID: number, bitmapChar: BitmapChar): void

- - Defined in lib/starling/text/BitmapFont.d.ts:74

  Adds a bitmap char with a certain character ID.

  #### Parameters

  - ##### charID: number

  - ##### bitmapChar: BitmapChar

  #### Returns void

### arrangeChars

- arrangeChars(width: number, height: number, text: string, format: TextFormat, options: TextOptions): Vector<BitmapCharLocation>

- - Defined in lib/starling/text/BitmapFont.d.ts:105

  Arranges the characters of text inside a rectangle, adhering to the given settings. Returns a Vector of BitmapCharLocations.

  BEWARE: This method uses an object pool for the returned vector and all (returned and temporary) BitmapCharLocation instances. Do not save any references and always call `BitmapCharLocation.rechargePool()` when you are done processing.

  #### Parameters

  - ##### width: number

  - ##### height: number

  - ##### text: string

  - ##### format: TextFormat

  - ##### options: TextOptions

  #### Returns Vector<BitmapCharLocation>

### clearMeshBatch

- clearMeshBatch(meshBatch: MeshBatch): void

- - Defined in lib/starling/text/BitmapFont.d.ts:91
  inheritdoc

  #### Parameters

  - ##### meshBatch: MeshBatch

  #### Returns void

### createSprite

- createSprite(width: number, height: number, text: string, format: TextFormat, options?: TextOptions): Sprite

- - Defined in lib/starling/text/BitmapFont.d.ts:83

  Creates a sprite that contains a certain text, made up by one image per char.

  #### Parameters

  - ##### width: number

  - ##### height: number

  - ##### text: string

  - ##### format: TextFormat

  - ##### Optional options: TextOptions

  #### Returns Sprite

### dispose

- dispose(): void

- - Defined in lib/starling/text/BitmapFont.d.ts:68

  Disposes the texture of the bitmap font!

  #### Returns void

### fillMeshBatch

- fillMeshBatch(meshBatch: MeshBatch, width: number, height: number, text: string, format: TextFormat, options?: TextOptions): void

- - Defined in lib/starling/text/BitmapFont.d.ts:87

  Draws text into a QuadBatch.

  #### Parameters

  - ##### meshBatch: MeshBatch

  - ##### width: number

  - ##### height: number

  - ##### text: string

  - ##### format: TextFormat

  - ##### Optional options: TextOptions

  #### Returns void

### getChar

- getChar(charID: number): BitmapChar

- - Defined in lib/starling/text/BitmapFont.d.ts:71

  Returns a single bitmap char with a certain character ID.

  #### Parameters

  - ##### charID: number

  #### Returns BitmapChar

### getCharIDs

- getCharIDs(result?: Vector<number>): Vector<number>

- - Defined in lib/starling/text/BitmapFont.d.ts:77

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

  #### Parameters

  - ##### Optional result: Vector<number>

  #### Returns Vector<number>

### getDefaultMeshStyle

- getDefaultMeshStyle(previousStyle: MeshStyle, format: TextFormat, options: TextOptions): MeshStyle

- - Defined in lib/starling/text/BitmapFont.d.ts:94
  inheritdoc

  #### Parameters

  - ##### previousStyle: MeshStyle

  - ##### format: TextFormat

  - ##### options: TextOptions

  #### Returns MeshStyle

### Protected get_baseline

- get_baseline(): number

- - Defined in lib/starling/text/BitmapFont.d.ts:140

  #### Returns number

### get_distanceFieldSpread

- get_distanceFieldSpread(): number

- - Defined in lib/starling/text/BitmapFont.d.ts:124

  #### Returns number

### Protected get_lineHeight

- get_lineHeight(): number

- - Defined in lib/starling/text/BitmapFont.d.ts:129

  #### Returns number

### Protected get_name

- get_name(): string

- - Defined in lib/starling/text/BitmapFont.d.ts:110

  #### Returns string

### Protected get_offsetX

- get_offsetX(): number

- - Defined in lib/starling/text/BitmapFont.d.ts:146

  #### Returns number

### Protected get_offsetY

- get_offsetY(): number

- - Defined in lib/starling/text/BitmapFont.d.ts:152

  #### Returns number

### Protected get_padding

- get_padding(): number

- - Defined in lib/starling/text/BitmapFont.d.ts:159

  #### Returns number

### Protected get_size

- get_size(): number

- - Defined in lib/starling/text/BitmapFont.d.ts:114

  #### Returns number

### Protected get_smoothing

- get_smoothing(): string

- - Defined in lib/starling/text/BitmapFont.d.ts:134

  #### Returns string

### Protected get_texture

- get_texture(): Texture

- - Defined in lib/starling/text/BitmapFont.d.ts:163

  The underlying texture that contains all the chars.

  #### Returns Texture

### get_type

- get_type(): string

- - Defined in lib/starling/text/BitmapFont.d.ts:118

  #### Returns string

### hasChars

- hasChars(text: string): boolean

- - Defined in lib/starling/text/BitmapFont.d.ts:80

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

  #### Parameters

  - ##### text: string

  #### Returns boolean

### Protected set_baseline

- set_baseline(value: number): number

- - Defined in lib/starling/text/BitmapFont.d.ts:141

  #### Parameters

  - ##### value: number

  #### Returns number

### set_distanceFieldSpread

- set_distanceFieldSpread(value: number): number

- - Defined in lib/starling/text/BitmapFont.d.ts:125

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_lineHeight

- set_lineHeight(value: number): void

- - Defined in lib/starling/text/BitmapFont.d.ts:130

  #### Parameters

  - ##### value: number

  #### Returns void

### Protected set_offsetX

- set_offsetX(value: number): number

- - Defined in lib/starling/text/BitmapFont.d.ts:147

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_offsetY

- set_offsetY(value: number): number

- - Defined in lib/starling/text/BitmapFont.d.ts:153

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_padding

- set_padding(value: number): number

- - Defined in lib/starling/text/BitmapFont.d.ts:160

  #### Parameters

  - ##### value: number

  #### Returns number

### Protected set_smoothing

- set_smoothing(value: string): string

- - Defined in lib/starling/text/BitmapFont.d.ts:135

  #### Parameters

  - ##### value: string

  #### Returns string

### set_type

- set_type(value: string): string

- - Defined in lib/starling/text/BitmapFont.d.ts:119

  #### Parameters

  - ##### value: string

  #### Returns string

Generated using TypeDoc