Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Font.cpp 954B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*!
  2. * \file src/Font.cpp
  3. * \brief Font implementation
  4. *
  5. * \author xythobuz
  6. */
  7. #include "global.h"
  8. #include "utils/strings.h"
  9. #include "Font.h"
  10. Font::~Font() {
  11. delete [] mFontName;
  12. mFontName = NULL;
  13. delete [] tempText.text;
  14. tempText.text = NULL;
  15. }
  16. void Font::setFont(const char *font) {
  17. assert(font != NULL);
  18. assert(font[0] != '\0');
  19. assert(mFontInit == false);
  20. mFontName = fullPath(font, 0);
  21. }
  22. void Font::drawText(unsigned int x, unsigned int y, float scale, const float color[4], const char *s, ...) {
  23. va_list args;
  24. va_start(args, s);
  25. vsnprintf(tempText.text, 256, s, args);
  26. tempText.text[255] = '\0';
  27. va_end(args);
  28. tempText.scale = scale;
  29. tempText.x = x;
  30. tempText.y = y;
  31. if (color) {
  32. tempText.color[0] = color[0];
  33. tempText.color[1] = color[1];
  34. tempText.color[2] = color[2];
  35. tempText.color[3] = color[3];
  36. }
  37. writeString(tempText);
  38. }