Inherits from NSObject
Declared in SPBitmapFont.h

Overview

The SPBitmapFont 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. 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>

You don’t have to use this class directly in most cases. SPTextField contains methods that handle bitmap fonts for you.

Tasks

Initialization

Methods

Properties

  •   name

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

    property
  •   size

    The native size of the font.

    property
  •   lineHeight

    The height of one line in pixels.

    property
  •   smoothing

    The smoothing filter used for the texture.

    property
  •   baseline

    The baseline of the font.

    property

Properties

baseline

The baseline of the font.

@property (nonatomic, readonly) float baseline

Discussion

The baseline of the font.

Declared In

SPBitmapFont.h

lineHeight

The height of one line in pixels.

@property (nonatomic, assign) float lineHeight

Discussion

The height of one line in pixels.

Declared In

SPBitmapFont.h

name

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

@property (nonatomic, readonly) NSString *name

Discussion

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

Declared In

SPBitmapFont.h

size

The native size of the font.

@property (nonatomic, readonly) float size

Discussion

The native size of the font.

Declared In

SPBitmapFont.h

smoothing

The smoothing filter used for the texture.

@property (nonatomic, assign) SPTextureSmoothing smoothing

Discussion

The smoothing filter used for the texture.

Declared In

SPBitmapFont.h

Instance Methods

charByID:

Returns a single bitmap char with a certain character ID.

- (SPBitmapChar *)charByID:(int)charID

Discussion

Returns a single bitmap char with a certain character ID.

Declared In

SPBitmapFont.h

createSpriteWithWidth:height:text:fontSize:color:hAlign:vAlign:autoScale:kerning:

Creates a sprite that contains the given text by arranging individual chars.

- (SPSprite *)createSpriteWithWidth:(float)width height:(float)height text:(NSString *)text fontSize:(float)size color:(uint)color hAlign:(SPHAlign)hAlign vAlign:(SPVAlign)vAlign autoScale:(BOOL)autoScale kerning:(BOOL)kerning

Discussion

Creates a sprite that contains the given text by arranging individual chars.

Declared In

SPBitmapFont.h

fillQuadBatch:withWidth:height:text:fontSize:color:hAlign:vAlign:autoScale:kerning:

Draws text into a quad batch.

- (void)fillQuadBatch:(SPQuadBatch *)quadBatch withWidth:(float)width height:(float)height text:(NSString *)text fontSize:(float)size color:(uint)color hAlign:(SPHAlign)hAlign vAlign:(SPVAlign)vAlign autoScale:(BOOL)autoScale kerning:(BOOL)kerning

Discussion

Draws text into a quad batch.

Declared In

SPBitmapFont.h

initWithContentsOfData:

Initializes a bitmap font by parsing the XML data and loading the texture that is specified there.

- (instancetype)initWithContentsOfData:(NSData *)data

Discussion

Initializes a bitmap font by parsing the XML data and loading the texture that is specified there.

Declared In

SPBitmapFont.h

initWithContentsOfData:texture:

Initializes a bitmap font by parsing the XML data and using the specified texture. Designated Initializer.

- (instancetype)initWithContentsOfData:(NSData *)data texture:(SPTexture *)texture

Discussion

Initializes a bitmap font by parsing the XML data and using the specified texture. Designated Initializer.

Declared In

SPBitmapFont.h

initWithContentsOfFile:

Initializes a bitmap font by parsing an XML file and loading the texture that is specified there.

- (instancetype)initWithContentsOfFile:(NSString *)path

Discussion

Initializes a bitmap font by parsing an XML file and loading the texture that is specified there.

Declared In

SPBitmapFont.h

initWithContentsOfFile:texture:

Initializes a bitmap font by parsing an XML file and using the specified texture.

- (instancetype)initWithContentsOfFile:(NSString *)path texture:(SPTexture *)texture

Discussion

Initializes a bitmap font by parsing an XML file and using the specified texture.

Declared In

SPBitmapFont.h

initWithMiniFont

Initializes a bitmap font with an integrated, very small font, which is useful for debug output.

- (instancetype)initWithMiniFont

Discussion

Initializes a bitmap font with an integrated, very small font, which is useful for debug output.

Declared In

SPBitmapFont.h