EmFont.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /***************************************************************************
  2. EmFont.h - description
  3. -------------------
  4. begin : Mon Jul 23 2001
  5. copyright : (C) 2001 by Henrik Enqvist
  6. email : henqvist@excite.com
  7. ***************************************************************************/
  8. #ifndef EMFONT_H
  9. #define EMFONT_H
  10. //#define EM_FONT_X_2 17
  11. //#define EM_FONT_Y_2 13
  12. #ifndef PRIVATE_H
  13. #error Must include Private.h before EmFont.h
  14. #endif
  15. #if EM_USE_SDL
  16. #define EM_FONTSIZE_X 0.06f*EM_RIGHT
  17. #define EM_FONTSIZE_Y 0.08f*EM_UP
  18. #endif
  19. #if EM_USE_ALLEGRO
  20. #define EM_FONTSIZE_X 0.03f
  21. #define EM_FONTSIZE_Y 0.04f
  22. #endif
  23. #include "TextureUtil.h"
  24. class Config;
  25. /** A singleton utility for fonts. */
  26. class EmFont {
  27. public:
  28. ~EmFont();
  29. /** Get singleton object. */
  30. static EmFont * getInstance();
  31. void loadFont(const char * fileName);
  32. /** If row is negative the row will be counted from bottom of screen. */
  33. void printRow(const char * buffer, float row);
  34. /** If row is negative the row will be counted from bottom of screen. */
  35. void printRowCenter(const char * buffer, float row);
  36. protected:
  37. #if EM_USE_SDL
  38. /** With OpenGL -1,1 is upper left. 1,-1 is lower right. */
  39. void print(const char * buffer, float x, float y);
  40. #endif
  41. #if EM_USE_ALLEGRO
  42. /** With allegro 0,0 is upper lefter. The screen size determines the lower right. */
  43. void print(const char * buffer, int x, int y);
  44. #endif
  45. EmFont();
  46. private:
  47. //EmImage * m_Font;
  48. EmTexture * m_Texture;
  49. int m_iSize;
  50. float m_fFontSizeX;
  51. float m_fFontSizeY;
  52. Config * p_Config;
  53. static EmFont * p_EmFont;
  54. };
  55. #endif // EMFONT_H