Font.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef INCLUDE_FONT_H
  2. #define INCLUDE_FONT_H
  3. #include "Graphics.h"
  4. #include "Texture.h"
  5. #include "piaf/Archive.h"
  6. #include "utility/Rect.h"
  7. namespace WalrusRPG
  8. {
  9. namespace Graphics
  10. {
  11. struct CharacterParameters
  12. {
  13. // Sprite clip
  14. WalrusRPG::Utils::Rect dimensions;
  15. // Character rendering offset
  16. int16_t x_offset, y_offset;
  17. };
  18. class Font
  19. {
  20. public:
  21. // Font height.
  22. uint8_t baseline;
  23. // Variable to override space's rendering width.
  24. uint8_t space_width;
  25. // Character dimensions/offset container.
  26. CharacterParameters chars[256];
  27. // Font texture
  28. // TODO?: Determine if using a reference or a variable.
  29. WalrusRPG::Graphics::Texture &font_tex;
  30. Font(WalrusRPG::Graphics::Texture &font_tex,
  31. WalrusRPG::PIAF::File font_config);
  32. ~Font();
  33. void draw(uint16_t x, uint16_t y, const char c) const;
  34. void draw(uint16_t x, uint16_t y, const char c,
  35. const WalrusRPG::Graphics::Pixel &col) const;
  36. void draw(uint16_t x, uint16_t y, const char *str) const;
  37. void draw(uint16_t x, uint16_t y, const char *str,
  38. const WalrusRPG::Graphics::Pixel &col) const;
  39. void draw_format(uint16_t x, uint16_t y, const char *format, ...) const;
  40. void draw_format(uint16_t x, uint16_t y,
  41. const WalrusRPG::Graphics::Pixel &col, const char *format,
  42. ...) const;
  43. };
  44. }
  45. }
  46. #endif