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 #ifndef SFONT_H 12 #define SFONT_H 13 14 #include "SDL.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 // Delcare one variable of this type for each font you are using. 21 // To load the fonts, load the font image into YourFont->Surface 22 // and call InitFont( YourFont ); 23 typedef struct { 24 SDL_Surface *Surface; 25 int CharPos[512]; 26 int h; 27 } SFont_FontInfo; 28 29 // Initializes the font 30 // Font: this contains the suface with the font. 31 // The font must be loaded before using this function. 32 void InitFont (SDL_Surface *Font); 33 void InitFont2(SFont_FontInfo *Font); 34 35 // Blits a string to a surface 36 // Destination: the suface you want to blit to 37 // text: a string containing the text you want to blit. 38 void PutString (SDL_Surface *Surface, int x, int y, char *text); 39 void PutString2(SDL_Surface *Surface, SFont_FontInfo *Font, int x, int y, char *text); 40 41 // Returns the width of "text" in pixels 42 int TextWidth(char *text); 43 int TextWidth2(SFont_FontInfo *Font, char *text); 44 45 // Blits a string to with centered x position 46 void XCenteredString (SDL_Surface *Surface, int y, char *text); 47 void XCenteredString2(SDL_Surface *Surface, SFont_FontInfo *Font, int y, char *text); 48 49 // Allows the user to enter text 50 // Width: What is the maximum width of the text (in pixels) 51 // text: This string contains the text which was entered by the user 52 void SFont_Input ( SDL_Surface *Destination, int x, int y, int Width, char *text); 53 void SFont_Input2( SDL_Surface *Destination, SFont_FontInfo *Font, int x, int y, int Width, char *text); 54 55 #ifdef __cplusplus 56 } 57 #endif 58 59 #endif /* SFONT_H */ 60