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