1 /************************************************************************ 2 * SFONT - SDL Font Library by Karl Bartel <karlb@gmx.net> * 3 * * 4 * All functions are explained below. There are two versions of each * 5 * funtction. The first is the normal one, the function with the * 6 * 2 at the end can be used when you want to handle more than one font * 7 * in your program. * 8 * * 9 ************************************************************************/ 10 11 #include <SDL.h> 12 13 // Delcare one variable of this type for each font you are using. 14 // To load the fonts, load the font image into YourFont->Surface 15 // and call InitFont( YourFont ); 16 typedef struct { 17 SDL_Surface *Surface; 18 int CharPos[512]; 19 int h; 20 } SFont_FontInfo; 21 22 // Initializes the font 23 // Font: this contains the suface with the font. 24 // The font must be loaded before using this function. 25 void InitFont (SDL_Surface *Font); 26 void InitFont2(SFont_FontInfo *Font); 27 28 // Blits a string to a surface 29 // Destination: the suface you want to blit to 30 // text: a string containing the text you want to blit. 31 void PutString (SDL_Surface *Surface, int x, int y, char *text); 32 void PutString2(SDL_Surface *Surface, SFont_FontInfo *Font, int x, int y, char *text); 33 34 // Returns the width of "text" in pixels 35 int TextWidth(char *text); 36 int TextWidth2(SFont_FontInfo *Font, char *text); 37 38 // Blits a string to with centered x position 39 void XCenteredString (SDL_Surface *Surface, int y, char *text); 40 void XCenteredString2(SDL_Surface *Surface, SFont_FontInfo *Font, int y, char *text); 41 42 // Allows the user to enter text 43 // Width: What is the maximum width of the text (in pixels) 44 // text: This string contains the text which was entered by the user 45 void SFont_Input ( SDL_Surface *Destination, int x, int y, int Width, char *text); 46 void SFont_Input2( SDL_Surface *Destination, SFont_FontInfo *Font, int x, int y, int Width, char *text); 47