- Main Page
- Data Structures
- Files

- File List

# SFont.h

    00001 /*  SFont: a simple font-library that uses special bitmaps as fonts
    00002     Copyright (C) 2003 Karl Bartel
    00003
    00004     License: GPL or LGPL (at your choice)
    00005     WWW: http://www.linux-games.com/sfont/
    00006
    00007     This program is free software; you can redistribute it and/or modify
    00008     it under the terms of the GNU General Public License as published by
    00009     the Free Software Foundation; either version 2 of the License, or
    00010     (at your option) any later version.
    00011
    00012     This program is distributed in the hope that it will be useful,
    00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00015     GNU General Public License for more details.
    00016
    00017     You should have received a copy of the GNU General Public License
    00018     along with this program; if not, write to the Free Software
    00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00020
    00021     Karl Bartel
    00022     Cecilienstr. 14
    00023     12307 Berlin
    00024     GERMANY
    00025     karlb@gmx.net
    00026 */
    00027
    00028 /************************************************************************
    00029 *    SFONT - SDL Font Library by Karl Bartel <karlb@gmx.net>            *
    00030 *                                                                       *
    00031 *  All functions are explained below. For further information, take a   *
    00032 *  look at the example files, the links at the SFont web site, or       *
    00033 *  contact me, if you problem isn' addressed anywhere.                  *
    00034 *                                                                       *
    00035 ************************************************************************/
    00036 #ifndef _SFONT_H_
    00037 #define _SFONT_H_
    00038
    00039 #include <SDL.h>
    00040
    00041 #ifdef __cplusplus
    00042 extern "C" {
    00043 #endif
    00044
    00045 // Delcare one variable of this type for each font you are using.
    00046 // To load the fonts, load the font image into YourFont->Surface
    00047 // and call InitFont( YourFont );
    00048 typedef struct {
    00049         SDL_Surface *Surface;
    00050         int CharPos[512];
    00051         int MaxPos;
    00052 } SFont_Font;
    00053
    00054 // Initializes the font
    00055 // Font: this contains the suface with the font.
    00056 //       The Surface must be loaded before calling this function
    00057 SFont_Font* SFont_InitFont (SDL_Surface *Font);
    00058
    00059 // Frees the font
    00060 // Font: The font to free
    00061 //       The font must be loaded before using this function.
    00062 void SFont_FreeFont(SFont_Font* Font);
    00063
    00064 // Blits a string to a surface
    00065 // Destination: the suface you want to blit to
    00066 // text: a string containing the text you want to blit.
    00067 void SFont_Write(SDL_Surface *Surface, const SFont_Font *Font, int x, int y,
    00068                                  const char *text);
    00069
    00070 // Returns the width of "text" in pixels
    00071 int SFont_TextWidth(const SFont_Font* Font, const char *text);
    00072 // Returns the height of "text" in pixels (which is always equal to Font->Surface->h)
    00073 int SFont_TextHeight(const SFont_Font* Font);
    00074
    00075 // Blits a string to Surface with centered x position
    00076 void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font* Font, int y,
    00077                                            const char *text);
    00078
    00079 #ifdef __cplusplus
    00080 }
    00081 #endif
    00082
    00083 #endif /* SFONT_H */