JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
easy mode; messages at game over.
[vor.git] / SFont.h
1 /*  SFont: a simple font-library that uses special bitmaps as fonts
2     Copyright (C) 2003 Karl Bartel
3
4     WWW: http://www.linux-games.com/sfont/
5
6     This program is free software; you can redistribute it and/or modify        
7     it under the terms of the GNU General Public License as published by        
8     the Free Software Foundation; either version 2 of the License, or           
9     (at your option) any later version.                                         
10                                                                                 
11     This program is distributed in the hope that it will be useful,       
12     but WITHOUT ANY WARRANTY; without even the implied warranty of              
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               
14     GNU General Public License for more details.                
15                                                                                
16     You should have received a copy of the GNU General Public License           
17     along with this program; if not, write to the Free Software                 
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   
19                                                                                 
20     Karl Bartel
21     Cecilienstr. 14                                                    
22     12307 Berlin
23     GERMANY
24     karlb@gmx.net                                                      
25 */                                                                            
26
27 /************************************************************************ 
28 *    SFONT - SDL Font Library by Karl Bartel <karlb@gmx.net>            *
29 *                                                                       *
30 *  All functions are explained below. For further information, take a   *
31 *  look at the example files, the links at the SFont web site, or       *
32 *  contact me, if you problem isn' addressed anywhere.                  *
33 *                                                                       *
34 ************************************************************************/
35 #ifndef SFONT_H
36 #define SFONT_H
37
38 #include <SDL.h>
39
40 // Delcare one variable of this type for each font you are using.
41 // To load the fonts, load the font image into YourFont->Surface
42 // and call SFont_InitFont(YourFont);
43 typedef struct {
44         SDL_Surface *Surface;   
45         int CharPos[512];
46         int MaxPos;
47 } SFont_Font;
48
49 // Initializes the font
50 // Font: this contains the suface with the font.
51 //       The Surface must be loaded before calling this function
52 SFont_Font* SFont_InitFont (SDL_Surface *Font);
53
54 // Frees the font
55 // Font: The font to free
56 //       The font must be loaded before using this function.
57 void SFont_FreeFont(SFont_Font* Font);
58
59 // Blits a string to a surface
60 // Destination: the suface you want to blit to
61 // text: a string containing the text you want to blit.
62 void SFont_Write(SDL_Surface *Surface, const SFont_Font *Font, int x, int y,
63                                  const char *text);
64
65 // Returns the width of "text" in pixels
66 int SFont_TextWidth(const SFont_Font* Font, const char *text);
67 // Returns the height of "text" in pixels (which is always equal to Font->Surface->h)
68 int SFont_TextHeight(const SFont_Font* Font);
69
70 // Blits a string to Surface with centered x position
71 void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font* Font, int y,
72                                            const char *text);
73
74 #endif /* SFONT_H */