Font.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 Font
  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. uint8_t baseline;
  22. uint8_t space_width;
  23. CharacterParameters chars[256];
  24. WalrusRPG::Graphics::Texture &font_tex;
  25. Font(WalrusRPG::Graphics::Texture &font_tex,
  26. WalrusRPG::PIAF::File font_config);
  27. ~Font();
  28. void draw(const char c, uint16_t x, uint16_t y);
  29. void draw(const char c, uint16_t x, uint16_t y,
  30. const WalrusRPG::Graphics::Pixel &col);
  31. void draw(const char *str, uint16_t x, uint16_t y);
  32. void draw(const char *str, uint16_t x, uint16_t y,
  33. const WalrusRPG::Graphics::Pixel &col);
  34. };
  35. }
  36. }
  37. #endif