Simple game engine with complete export to scripting language
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.
 
 
 

71 lines
1.2 KiB

  1. #ifndef BLUECORE_FONT_MANAGER_H
  2. #define BLUECORE_FONT_MANAGER_H
  3. // system includes
  4. #include <map>
  5. #include <string>
  6. // project includes
  7. #include "Utilities/Referenced.h"
  8. #include "RenderDevice.h"
  9. // forward declaratins
  10. class FTFont;
  11. namespace BlueCore
  12. {
  13. class Font : public Referenced
  14. {
  15. FTFont *_Font;
  16. unsigned char *_Buffer;
  17. ref_ptr<RenderDevice> _Device;
  18. protected:
  19. ~Font();
  20. public:
  21. Font(FTFont *font, unsigned char *buffer, RenderDevice *device);
  22. Font();
  23. void destroy();
  24. void print(float x, float y, const std::string &text, int halign = 0,
  25. int valign = 0) const;
  26. };
  27. class FontManager : public Referenced, public sigslot::has_slots<>
  28. {
  29. private:
  30. typedef std::map<std::string, weak_ptr<Font> > FontMap;
  31. FontMap _fonts;
  32. ref_ptr<Font> _DefaultFont;
  33. void FontDestroyedSlot(Referenced*);
  34. void DeviceShutdownSlot();
  35. void destroy();
  36. public:
  37. FontManager(RenderDevice* device);
  38. ~FontManager();
  39. Font *loadFont(const std::string &name, int size, bool hinting = true);
  40. Font *getDefaultFont();
  41. private:
  42. ref_ptr<RenderDevice> _Device;
  43. };
  44. } // namespace BlueCore
  45. #endif // BLUECORE_FONT_MANAGER_H