Open Source Tomb Raider Engine
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Font.cpp 998B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. }
  14. void Font::setFont(const char *font) {
  15. assert(font != NULL);
  16. assert(font[0] != '\0');
  17. assert(mFontInit == false);
  18. mFontName = fullPath(font, 0);
  19. }
  20. void Font::drawText(unsigned int x, unsigned int y, float scale, const unsigned char color[4], const char *s, ...) {
  21. FontString tempText;
  22. va_list args;
  23. va_start(args, s);
  24. tempText.text = new char[256];
  25. tempText.scale = scale;
  26. tempText.w = 0;
  27. tempText.h = 0;
  28. tempText.x = x;
  29. tempText.y = y;
  30. tempText.color[0] = color[0];
  31. tempText.color[1] = color[1];
  32. tempText.color[2] = color[2];
  33. tempText.color[3] = color[3];
  34. vsnprintf(tempText.text, 256, s, args);
  35. tempText.text[255] = '\0';
  36. writeString(tempText);
  37. delete [] tempText.text;
  38. va_end(args);
  39. }