Gel2D - The free/open source game creation suite

gelFont.h
Go to the documentation of this file.
00001 /*
00002 Gel2D Game Engine - Cross-platform 2D gaming middleware
00003 Copyright (C) 2010-2011 Mark D. Procarione
00004 
00005 Gel2D is free software: you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation, either version 3 of the License, or
00008 (at your option) any later version.
00009 
00010 Gel2D is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013 GNU General Public License for more details.
00014 */
00015 
00016 #ifndef __GELFONT_H__
00017 #define __GELFONT_H__
00018 
00019 #include "gelString.h"
00020 #include "gelSprite.h"
00021 
00022 #define GEL2D_BMPFNT_HEADER "GEL2D_BMPFNT_v0.1"
00023 #define GEL2D_FONT_HEADER "GEL2D_FONT_v0.1"
00024 
00025 namespace gel
00026 {
00028     struct GelFontChar
00029     {
00030                 GelFontChar();
00031 
00032         GelVert v[4];
00033 
00034         Gel2dVec pos;
00035         float rot;
00036         Gel2dVec scl;
00037 
00038         GelColor col;
00039 
00040         int width;
00041         int height;
00042 
00043         int kernx;
00044         int kerny;
00045     };
00046 
00048 
00054         class GelFont
00055     {
00056                 public:
00058                         GelFont();
00059 
00061 
00062                         GelFont( GelString filename, ImageType type );
00063 
00065 
00066                         GelFont( GelString filename );
00067 
00069                         ~GelFont();
00070 
00072 
00073                         bool loadFont( GelString filename, int start, int stop, int height, int padding, int spacing, bool usealpha, bool antialias );
00074 
00076 
00081             bool readBmpFont( GelString filename, ImageType type );
00082 
00084 
00089             bool writeBmpFont( GelString filename, ImageType type );
00090 
00092 
00096             bool readFont( GelString filename );
00097 
00099 
00101             bool writeFont( GelString filename, GelString fontname, int start, int stop, int height, int padding, int spacing, bool usealpha, bool antialias  );
00102 
00104 
00105             GelTexture *getTexture() const { return texture; }
00106 
00108             int getLineHeight() const { return lineHeight; }
00109 
00110                 public:
00111                         GelFontChar fchar[256];
00112 
00113         private:
00114             int lineHeight;
00115             GELubyte *buf;
00116             GelTexture *texture;
00117         };
00118 }
00119 
00120 #endif // __GELFONT_H__