SPBitmapFont Class Reference
| 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
-
– initWithContentsOfData:texture:Initializes a bitmap font by parsing the XML data and using the specified texture. Designated Initializer.
-
– initWithContentsOfData:Initializes a bitmap font by parsing the XML data and loading the texture that is specified there.
-
– initWithContentsOfFile:texture:Initializes a bitmap font by parsing an XML file and using the specified texture.
-
– initWithContentsOfFile:Initializes a bitmap font by parsing an XML file and loading the texture that is specified there.
-
– initWithMiniFontInitializes a bitmap font with an integrated, very small font, which is useful for debug output.
Methods
-
– charByID:Returns a single bitmap char with a certain character ID.
-
– createSpriteWithWidth:height:text:fontSize:color:hAlign:vAlign:autoScale:kerning:Creates a sprite that contains the given text by arranging individual chars.
-
– fillQuadBatch:withWidth:height:text:fontSize:color:hAlign:vAlign:autoScale:kerning:Draws text into a quad batch.
Properties
-
nameThe name of the font as it was parsed from the font file.
property -
sizeThe native size of the font.
property -
lineHeightThe height of one line in pixels.
property -
smoothingThe smoothing filter used for the texture.
property -
baselineThe baseline of the font.
property
Properties
baseline
The baseline of the font.
@property (nonatomic, readonly) float baselineDiscussion
The baseline of the font.
Declared In
SPBitmapFont.hlineHeight
The height of one line in pixels.
@property (nonatomic, assign) float lineHeightDiscussion
The height of one line in pixels.
Declared In
SPBitmapFont.hname
The name of the font as it was parsed from the font file.
@property (nonatomic, readonly) NSString *nameDiscussion
The name of the font as it was parsed from the font file.
Declared In
SPBitmapFont.hInstance Methods
charByID:
Returns a single bitmap char with a certain character ID.
- (SPBitmapChar *)charByID:(int)charIDDiscussion
Returns a single bitmap char with a certain character ID.
Declared In
SPBitmapFont.hcreateSpriteWithWidth: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)kerningDiscussion
Creates a sprite that contains the given text by arranging individual chars.
Declared In
SPBitmapFont.hfillQuadBatch: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)kerningDiscussion
Draws text into a quad batch.
Declared In
SPBitmapFont.hinitWithContentsOfData:
Initializes a bitmap font by parsing the XML data and loading the texture that is specified there.
- (instancetype)initWithContentsOfData:(NSData *)dataDiscussion
Initializes a bitmap font by parsing the XML data and loading the texture that is specified there.
Declared In
SPBitmapFont.hinitWithContentsOfData:texture:
Initializes a bitmap font by parsing the XML data and using the specified texture. Designated Initializer.
- (instancetype)initWithContentsOfData:(NSData *)data texture:(SPTexture *)textureDiscussion
Initializes a bitmap font by parsing the XML data and using the specified texture. Designated Initializer.
Declared In
SPBitmapFont.hinitWithContentsOfFile:
Initializes a bitmap font by parsing an XML file and loading the texture that is specified there.
- (instancetype)initWithContentsOfFile:(NSString *)pathDiscussion
Initializes a bitmap font by parsing an XML file and loading the texture that is specified there.
Declared In
SPBitmapFont.hinitWithContentsOfFile:texture:
Initializes a bitmap font by parsing an XML file and using the specified texture.
- (instancetype)initWithContentsOfFile:(NSString *)path texture:(SPTexture *)textureDiscussion
Initializes a bitmap font by parsing an XML file and using the specified texture.
Declared In
SPBitmapFont.h