1 
2 /******************************************************************************
3  *         MODIFIED MY JUAN PEDRO BOLIVAR FOR BETTER INTEGRATION IN           *
4  * 		   THIS PROJECT.					      *
5  ******************************************************************************/
6 /*  Only works on THIS project */
7 
8 
9 /*  SFont: a simple font-library that uses special bitmaps as fonts
10     Copyright (C) 2003 Karl Bartel
11 
12     License: GPL or LGPL (at your choice)
13     WWW: http://www.linux-games.com/sfont/
14 
15     This program is free software; you can redistribute it and/or modify
16     it under the terms of the GNU General Public License as published by
17     the Free Software Foundation; either version 2 of the License, or
18     (at your option) any later version.
19 
20     This program is distributed in the hope that it will be useful,
21     but WITHOUT ANY WARRANTY; without even the implied warranty of
22     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23     GNU General Public License for more details.
24 
25     You should have received a copy of the GNU General Public License
26     along with this program; if not, write to the Free Software
27     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 
29     Karl Bartel
30     Cecilienstr. 14
31     12307 Berlin
32     GERMANY
33     karlb@gmx.net
34 */
35 
36 /************************************************************************
37 *    SFONT - SDL Font Library by Karl Bartel <karlb@gmx.net>            *
38 *                                                                       *
39 *  All functions are explained below. For further information, take a   *
40 *  look at the example files, the links at the SFont web site, or       *
41 *  contact me, if you problem isn' addressed anywhere.                  *
42 *                                                                       *
43 ************************************************************************/
44 #ifndef SFONT_H
45 #define SFONT_H
46 
47 #include <SDL/SDL.h>
48 #include <string.h>
49 
50 #include "surface.h"
51 
52 #ifdef __cplusplus
53 extern "C"
54 {
55 #endif
56 
57   /* Added by Juan Pedro Bolíar */
58 #define ALEFT 0
59 #define ACENTER 1
60 #define ARIGHT 2
61 
62 // Delcare one variable of this type for each font you are using.
63 // To load the fonts, load the font image into YourFont->Surface
64 // and call InitFont( YourFont );
65   typedef struct
66   {
67     JPB_surface *Surface;
68     int CharPos[512];
69     int MaxPos;
70   }
71   SFont_Font;
72 
73 // Initializes the font
74 // Font: this contains the suface with the font.
75 //       The Surface must be loaded before calling this function
76 //SFont_Font* SFont_InitFont (SDL_Surface *Font);
77   SFont_Font *SFont_InitFont (char *file, SDL_Surface * Surface, Uint8 gl,
78 			      Uint8 alpha);
79 
80 // Frees the font
81 // Font: The font to free
82 //       The font must be loaded before using this function.
83   void SFont_FreeFont (SFont_Font * Font);
84 
85 // Blits a string to a surface
86 // Destination: the suface you want to blit to
87 // text: a string containing the text you want to blit.
88   void SFont_Write (SFont_Font * Font, int x, int y, char *text);
89 
90 // Returns the width of "text" in pixels
91   int SFont_TextWidth (const SFont_Font * Font, const char *text);
92 // Returns the height of "text" in pixels (which is always equal to Font->Surface->h)
93   int SFont_TextHeight (const SFont_Font * Font);
94 
95 // Blits a string to Surface with centered x position
96   void SFont_WriteCenter (SDL_Surface * Surface, SFont_Font * Font,
97 			  int y, char *text);
98 
99   /* Blits a string aligned in a square defined by X, Y and W. */
100   void SFont_WriteAligned (SFont_Font * Font, int x, int y, int w,
101 			   int gap, int align, char *text);
102 
103   /* Returns the heigth of a multi-line text */
104   int SFont_AlignedHeight (SFont_Font * Font, int w, int gap, char *text);
105 
106   int SFont_FillWith (SFont_Font * Font, int x, int y, int w, char c);
107 
108   void SFont_WriteMaxWidth (SFont_Font * Font, int x, int y, int w,
109 			    int align, char *tag, char *text);
110 
111   int SFont_SetAlpha (SFont_Font * font, int alpha);
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif				/* SFONT_H */
118