git repos / blockattack-game

blame: source/code/SFont.h

normal view · raw

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