FontWriter.h 951 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. /**
  5. * Font writer for fixed-width static fonts.
  6. *
  7. *
  8. */
  9. #ifndef __FONTWRITER__
  10. #define __FONTWRITER__
  11. #include "../spritebatchqt/src_general/SpriteBatch.h"
  12. #define CHAR_EXTEND_MUL 1.5f
  13. class PongApp;
  14. class FontWriter {
  15. public:
  16. FontWriter( SpriteBatch *batch, unsigned int textureID, int xdiv, int ydiv, char *characters );
  17. ~FontWriter();
  18. void setColor( float *color );
  19. void setColor( float r, float g, float b, float a );
  20. void writeText( const char *text, float xpos, float ypos, float scale );
  21. float getTextWidth( const char *text, float scale );
  22. protected:
  23. SpriteBatch *spriteBatch;
  24. float currentColor[4];
  25. struct SCharacter {
  26. bool enabled;
  27. float offsetScale[4];
  28. };
  29. SCharacter charMap[128];
  30. unsigned int texture;
  31. int xdivision;
  32. int ydivision;
  33. };
  34. #endif