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