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 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*!
  2. * \file src/Font.cpp
  3. * \brief Font implementation
  4. *
  5. * \author xythobuz
  6. */
  7. #include <stdio.h>
  8. #include <stdarg.h>
  9. #include "global.h"
  10. #include "utils/strings.h"
  11. #include "Font.h"
  12. Font::~Font() {
  13. delete [] mFontName;
  14. mFontName = 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 unsigned char color[4], const char *s, ...) {
  23. FontString tempText;
  24. va_list args;
  25. va_start(args, s);
  26. tempText.text = new char[256];
  27. tempText.scale = scale;
  28. tempText.w = 0;
  29. tempText.h = 0;
  30. tempText.x = x;
  31. tempText.y = y;
  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. vsnprintf(tempText.text, 256, s, args);
  37. tempText.text[255] = '\0';
  38. writeString(tempText);
  39. delete [] tempText.text;
  40. va_end(args);
  41. }