FONT.H 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef __FONT_H
  2. #define __FONT_H
  3. #include <limits.h>
  4. #include <stdarg.h>
  5. #include "globals.h"
  6. #define kFontNameSize 7
  7. #define kFontMaxTiles (SCHAR_MAX + 1)
  8. #define kFontMaxText 128
  9. #define kFontNoTile -1
  10. #define kFontVersion 0x0100
  11. #define kFontSig "FNT\x1A"
  12. enum {
  13. kFontJustLeft = 0x01,
  14. kFontJustRight = 0x02,
  15. kFontJustCenter = 0x03,
  16. };
  17. struct FONTHEADER
  18. {
  19. char signature[ 4 ];
  20. short version;
  21. };
  22. struct FONTDATA {
  23. FONTHEADER header;
  24. char name[ kFontNameSize + 1 ];
  25. uchar charSpace;
  26. uchar lineSpace;
  27. uchar wordSpace;
  28. short firstTile;
  29. schar tileOffset[ kFontMaxTiles ];
  30. short tileWidth[ kFontMaxTiles ];
  31. };
  32. class Font {
  33. RESHANDLE hFont;
  34. FONTDATA *pFont;
  35. private:
  36. // if nTile == -1, text is drawn to the screen
  37. // justFlags enumerated in FONT.H
  38. int DrawText( int nDestTile, unsigned justFlags, int x, int y, char *zText );
  39. public:
  40. Font(void);
  41. // ~Font();
  42. void Load( char *zName );
  43. void Unload( void );
  44. int Print( int x, int y, char *zFormat, ... );
  45. int Center( int x, int y, char *zFormat, ... );
  46. int Draw( int nTile, int x, int y, char *zFormat, ... );
  47. };
  48. #endif /* __FONT_H */