1 #ifndef _GUI_font_h 2 #define _GUI_font_h 3 4 #include <string.h> 5 6 #include "SDL.h" 7 8 class GUI_Font 9 { 10 11 public: 12 /* use default 8x8 font */ 13 GUI_Font(); 14 15 /* open named BMP file */ 16 GUI_Font(char *name); 17 18 /* use given YxY surface */ 19 GUI_Font(SDL_Surface *bitmap); 20 21 /* copy constructor */ 22 GUI_Font(GUI_Font& font); 23 24 ~GUI_Font(); 25 26 /* determine drawing style */ 27 virtual void SetTransparency(int on); 28 29 /* determine foreground and background color values RGB*/ 30 virtual void SetColoring(Uint8 fr, Uint8 fg, Uint8 fb, Uint8 br=255, Uint8 bg=255, Uint8 bb=255); 31 32 /* yields the pixel height of a single character */ CharHeight()33 inline virtual int CharHeight() 34 {return charh-1;} 35 36 /* yields the pixel width of a single character */ CharWidth()37 inline virtual int CharWidth() 38 {return charw;} 39 40 /* yields pixel width and height of a string when printed with this font */ TextExtent(char * text,int * w,int * h)41 inline virtual void TextExtent(char *text, int *w, int *h) 42 {*w=strlen(text)*charw; *h=charh-1;} 43 44 /* put the text onto the given surface using the preset mode and colors */ 45 virtual void TextOut(SDL_Surface *context, int x, int y, char* text); 46 47 protected: 48 /* the font source surface */ 49 SDL_Surface *fontStore; 50 51 /* flags */ 52 int transparent; 53 int freefont; 54 55 /* dimensions */ 56 int charh,charw; 57 }; 58 59 #endif /* _GUI_font_h */ 60