00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __BFONT_HEADER_H__
00009 #define __BFONT_HEADER_H__
00010
00011 #include <iostream>
00012 #include <SDL/SDL.h>
00013
00014 class BFont
00015 {
00016 int h;
00017 SDL_Surface *Surface;
00018 SDL_Rect Chars[256];
00019 const char* name;
00020
00021 BFont(const BFont&);
00022
00023 void InitFont();
00024 int count(const char *text);
00025 public:
00026
00027 BFont(const char *__filename)
00028 : name(__filename)
00029 { LoadFont(__filename); }
00030
00031 ~BFont()
00032 { SDL_FreeSurface(Surface); }
00033
00034 int FontHeight ()
00035 { return h; }
00036
00037 void SetFontHeight (int height)
00038 { h = height ; }
00039
00040 int CharWidth (char c)
00041 { return Chars[c].w; }
00042
00043 void LoadFont (const char *filename);
00044 int PutChar (SDL_Surface *screen, int x, int y, char c);
00045 int TextWidth (const char *text );
00046
00047 BFont *SetFontColor(Uint8 r, Uint8 g, Uint8 b);
00048
00049 void PutString ( SDL_Surface *screen, int x, int y, const char *text);
00050 void LeftPutString ( SDL_Surface *screen, int y, const char *text);
00051 void CenteredPutString ( SDL_Surface *screen, int y, const char *text);
00052 void RightPutString ( SDL_Surface *screen, int y, const char *text);
00053 void JustifiedPutString ( SDL_Surface *screen, int y, const char *text);
00054
00055
00056 void PrintString ( SDL_Surface *screen, int x, int y, char *fmt, ...);
00057 void CenteredPrintString ( SDL_Surface *screen, int y, char *fmt, ...);
00058 void RightPrintString ( SDL_Surface *screen, int y, char *fmt, ...);
00059 void LeftPrintString ( SDL_Surface *screen, int y, char *fmt, ...);
00060 void JustifiedPrintString ( SDL_Surface *screen, int y, char *fmt, ...);
00061
00062 private:
00063 Uint32 GetPixel( Sint32 X, Sint32 Y);
00064 Uint32 xGetPixel(SDL_Surface *surface, int x, int y);
00065 void PutPixel( SDL_Surface *,int x, int y, Uint32 pixel);
00066
00067 };
00068
00069 #endif // __BFONT_HEADER_H__
00070