author | andyq <andyq> | 2003-01-20 23:11:56 (UTC) |
---|---|---|
committer | andyq <andyq> | 2003-01-20 23:11:56 (UTC) |
commit | 92419b025aa5d82bb7592281af5505ff931c2e58 (patch) (unidiff) | |
tree | 374ee9ca86ef716ce388c8a28e38261f6a04ce7a /noncore/games/sfcave-sdl/bfont.h | |
parent | 02090d2e63ad8398c0a8a9f1fb895a9c6e42514b (diff) | |
download | opie-92419b025aa5d82bb7592281af5505ff931c2e58.zip opie-92419b025aa5d82bb7592281af5505ff931c2e58.tar.gz opie-92419b025aa5d82bb7592281af5505ff931c2e58.tar.bz2 |
Initial Revision
Diffstat (limited to 'noncore/games/sfcave-sdl/bfont.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/sfcave-sdl/bfont.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/noncore/games/sfcave-sdl/bfont.h b/noncore/games/sfcave-sdl/bfont.h new file mode 100644 index 0000000..dee97f1 --- a/dev/null +++ b/noncore/games/sfcave-sdl/bfont.h | |||
@@ -0,0 +1,70 @@ | |||
1 | |||
2 | /************************************************************ | ||
3 | |||
4 | BFONT v. 1.0.2 - Billi Font Library by Diego Billi | ||
5 | BFONT++ C++ port by Gianluigi Davassi | ||
6 | ************************************************************/ | ||
7 | |||
8 | #ifndef __BFONT_HEADER_H__ | ||
9 | #define __BFONT_HEADER_H__ | ||
10 | |||
11 | #include <iostream> | ||
12 | #include "SDL.h" | ||
13 | |||
14 | class BFont | ||
15 | { | ||
16 | int h; // font height | ||
17 | SDL_Surface *Surface; // font surface | ||
18 | SDL_Rect Chars[256]; // characters width | ||
19 | const char* name; // font name | ||
20 | |||
21 | BFont(const BFont&); | ||
22 | |||
23 | void InitFont(); | ||
24 | int count(const char *text); | ||
25 | public: | ||
26 | |||
27 | BFont(const char *__filename) // generator bill | ||
28 | : name(__filename) | ||
29 | { LoadFont(__filename); } | ||
30 | |||
31 | ~BFont() | ||
32 | { SDL_FreeSurface(Surface); } // screen must be free by application | ||
33 | |||
34 | int FontHeight () // Returns the font height | ||
35 | { return h; } | ||
36 | |||
37 | void SetFontHeight (int height) // Change the font height | ||
38 | { h = height ; } | ||
39 | |||
40 | int CharWidth (char c) // Returns the character width of the specified font | ||
41 | { return Chars[c].w; } | ||
42 | |||
43 | void LoadFont (const char *filename); // Load and store le font in the BFont structure | ||
44 | int PutChar (SDL_Surface *screen, int x, int y, char c); // Write a single character on the "Surface" with the current font | ||
45 | int TextWidth (const char *text ); // Returns the width, in pixels, of the text calculated with the current font | ||
46 | |||
47 | BFont *SetFontColor(Uint8 r, Uint8 g, Uint8 b); // Returns a new font colored with the color (r,g,b) | ||
48 | |||
49 | void PutString ( SDL_Surface *screen, int x, int y, const char *text); // Write a string on the "Surface" with the specified font | ||
50 | void LeftPutString ( SDL_Surface *screen, int y, const char *text); // Write a left-aligned string on the "Surface" with the specified font | ||
51 | void CenteredPutString ( SDL_Surface *screen, int y, const char *text); // Write a center-aligned string on the "Surface" with the specified font | ||
52 | void RightPutString ( SDL_Surface *screen, int y, const char *text); // Write a right-aligned string on the "Surface" with the specified font | ||
53 | void JustifiedPutString ( SDL_Surface *screen, int y, const char *text); // Write a justify-aligned string on the "Surface" with the specified font | ||
54 | |||
55 | // The following functions do the same task but have the classic "printf" sintax | ||
56 | void PrintString ( SDL_Surface *screen, int x, int y, char *fmt, ...); | ||
57 | void CenteredPrintString ( SDL_Surface *screen, int y, char *fmt, ...); | ||
58 | void RightPrintString ( SDL_Surface *screen, int y, char *fmt, ...); | ||
59 | void LeftPrintString ( SDL_Surface *screen, int y, char *fmt, ...); | ||
60 | void JustifiedPrintString ( SDL_Surface *screen, int y, char *fmt, ...); | ||
61 | |||
62 | private: | ||
63 | Uint32 GetPixel( Sint32 X, Sint32 Y); | ||
64 | Uint32 xGetPixel(SDL_Surface *surface, int x, int y); | ||
65 | void PutPixel( SDL_Surface *,int x, int y, Uint32 pixel); | ||
66 | |||
67 | }; | ||
68 | |||
69 | #endif // __BFONT_HEADER_H__ | ||
70 | |||