CmFont.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmResource.h"
  4. #include "CmFontDesc.h"
  5. namespace BansheeEngine
  6. {
  7. struct CM_EXPORT FontData : public IReflectable
  8. {
  9. UINT32 size;
  10. FONT_DESC fontDesc;
  11. Vector<HTexture> 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(const Vector<FontData>& 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> 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(const Vector<FontData>& fontInitData);
  50. static FontPtr _createPtr(const Vector<FontData>& fontInitData);
  51. };
  52. }