NXEngine v1.0.0.5
[NXEngine.git] / graphics / font.h
blob7494dd8f0a749f2bdbd3e9e89bfa7992899e2e1c
2 #ifndef _FONT_H
3 #define _FONT_H
5 // I don't want to needlessly include <SDL_ttf.h> in every file that
6 // includes this one so this forward declaration makes those modules
7 // that don't what a TTF_Font is shut up about InitChars(); however
8 // technically TTF_Font is a typedef, so if the including file knows
9 // the real declaration, it would bawk at this.
10 #ifndef SDL_TTF_VERSION
11 struct TTF_Font;
12 #endif
14 #define NUM_FONT_LETTERS 256
15 #define NUM_LETTERS_RENDERED 128
16 #define FONT_DEFAULT_SPACING 5
18 class NXFont
20 public:
21 NXFont();
22 ~NXFont();
24 bool InitChars(TTF_Font *font, uint32_t color);
25 bool InitCharsShadowed(TTF_Font *top, uint32_t color, uint32_t shadowcolor);
27 bool InitBitmapChars(SDL_Surface *sheet, uint32_t fgcolor, uint32_t color);
28 bool InitBitmapCharsShadowed(SDL_Surface *sheet, uint32_t fgcolor, uint32_t color, uint32_t shadowcolor);
30 void free();
32 SDL_Surface *letters[NUM_FONT_LETTERS];
34 private:
35 void ReplaceColor(SDL_Surface *sfc, uint32_t oldcolor, uint32_t newcolor);
39 extern NXFont whitefont;
40 extern NXFont greenfont;
41 extern NXFont bluefont; // used for "F3:Options" text on pause screen
42 extern NXFont shadowfont; // white letters w/ drop shadow
44 int font_draw(int x, int y, const char *text, int spacing=0, NXFont *font=&whitefont);
45 int font_draw_shaded(int x, int y, const char *text, int spacing=0, NXFont *font=&whitefont);
47 int GetFontWidth(const char *text, int spacing=0, bool is_shaded=false);
48 int GetFontHeight();
50 #endif