A little while ago, I wrote myself a sprite font system (No kerning, but I didn't require one for my purposes...) Here's the code:
void QuickText ( char* Text, int PositionX, int PositionY ) //Displays text free from the box constraint.
{
dbSprite ( TextSprite, PositionX, PositionY, TextImage ); //Position the string object.
int itimer = dbLen( Text ); //Set the timer to the character length of the text.
int wid = dbSpriteWidth ( TextSprite ) - 2; //The width of each letter. Small values make them closer together.
dbSetSpriteAlpha ( TextSprite, 255 ); //Change this to make the text transparent. Can be used to fade text in or out.
for ( int i = 1; i <= itimer; i++ )
{
//The text runs under an ASCII base, not a SCANCODE base.
dbSetSpriteFrame ( TextSprite, dbAsc( dbMid( Text, i ) ) - 31 );
dbPasteSprite ( TextSprite, PositionX + ( i * wid ), PositionY );
}
return;
}
And attatched is a bitmap font. Everything's pretty well labeled, so changing the system shouldn't be hard. It runs by reading a string's ASCII codes, and pasting the apropriate letter at a calculated position. Nothing special.
Using this function, you can use multiple font images at no cost to the game's performance, as each font requires only ONE sprite!
It's been fun: So long, TGC!