Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BitmapFont

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

Index

Constructors

constructor

  • 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

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

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

The height of one line in points.

name

name: string

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

offsetX

offsetX: number

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

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

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

The native size of the font.

smoothing

smoothing: string

The smoothing filter that is used for the texture.

type

type: string

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

Static MINI

MINI: string

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

Static NATIVE_SIZE

NATIVE_SIZE: number

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

arrangeChars

  • 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

    Returns Vector<BitmapCharLocation>

clearMeshBatch

createSprite

dispose

  • dispose(): void

fillMeshBatch

getChar

getCharIDs

  • getCharIDs(result?: Vector<number>): Vector<number>
  • Returns a vector containing all the character IDs that are contained in this font.

    Parameters

    • Optional result: Vector<number>

    Returns Vector<number>

getDefaultMeshStyle

Protected get_baseline

  • get_baseline(): number

get_distanceFieldSpread

  • get_distanceFieldSpread(): number

Protected get_lineHeight

  • get_lineHeight(): number

Protected get_name

  • get_name(): string

Protected get_offsetX

  • get_offsetX(): number

Protected get_offsetY

  • get_offsetY(): number

Protected get_padding

  • get_padding(): number

Protected get_size

  • get_size(): number

Protected get_smoothing

  • get_smoothing(): string

Protected get_texture

get_type

  • get_type(): string

hasChars

  • hasChars(text: string): boolean

Protected set_baseline

  • set_baseline(value: number): number

set_distanceFieldSpread

  • set_distanceFieldSpread(value: number): number

Protected set_lineHeight

  • set_lineHeight(value: number): void

Protected set_offsetX

  • set_offsetX(value: number): number

Protected set_offsetY

  • set_offsetY(value: number): number

Protected set_padding

  • set_padding(value: number): number

Protected set_smoothing

  • set_smoothing(value: string): string

set_type

  • set_type(value: string): string

Generated using TypeDoc