CmFont.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmResource.h"
  4. #include "CmFontDesc.h"
  5. namespace CamelotFramework
  6. {
  7. struct CM_EXPORT FontData : public IReflectable
  8. {
  9. UINT32 size;
  10. FONT_DESC fontDesc;
  11. Vector<HTexture>::type texturePages;
  12. const CHAR_DESC& getCharDesc(UINT32 charId) const;
  13. /************************************************************************/
  14. /* SERIALIZATION */
  15. /************************************************************************/
  16. public:
  17. friend class FontDataRTTI;
  18. static RTTITypeBase* getRTTIStatic();
  19. virtual RTTITypeBase* getRTTI() const;
  20. };
  21. // TODO - When saved on disk font currently stores a copy of the texture pages. This should be acceptable
  22. // if you import a new TrueType or OpenType font since the texture will be generated on the spot
  23. // but if you use a bitmap texture to initialize the font manually, then you will potentially have duplicate textures.
  24. // Also, changing the source texture will not automatically update the font because there is no direct link between them.
  25. // -- This is probably not a large problem, but it is something to keep an eye out.
  26. class CM_EXPORT Font : public Resource
  27. {
  28. public:
  29. virtual ~Font();
  30. void initialize(Vector<FontData>::type& fontData);
  31. const FontData* getFontDataForSize(UINT32 size) const;
  32. INT32 getClosestAvailableSize(UINT32 size) const;
  33. protected:
  34. friend class FontManager;
  35. Font();
  36. private:
  37. Map<UINT32, FontData>::type mFontDataPerSize;
  38. /************************************************************************/
  39. /* SERIALIZATION */
  40. /************************************************************************/
  41. public:
  42. friend class FontRTTI;
  43. static RTTITypeBase* getRTTIStatic();
  44. virtual RTTITypeBase* getRTTI() const;
  45. /************************************************************************/
  46. /* STATICS */
  47. /************************************************************************/
  48. public:
  49. static HFont create(Vector<FontData>::type& fontInitData);
  50. };
  51. }