BsScriptFontBitmap.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include "BsScriptEnginePrerequisites.h"
  3. #include "BsScriptResource.h"
  4. #include "BsScriptObject.h"
  5. #include "BsFont.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Describes a single character in a font of a specific size.
  10. */
  11. struct ScriptCharDesc // Note: Must match C# struct CharDesc
  12. {
  13. UINT32 charId; /**< Character ID, corresponding to a Unicode key. */
  14. UINT32 page; /**< Index of the texture the character is located on. */
  15. float uvX, uvY; /**< Texture coordinates of the character in the page texture. */
  16. float uvWidth, uvHeight; /**< Width/height of the character in texture coordinates. */
  17. UINT32 width, height; /**< Width/height of the character in pixels. */
  18. INT32 xOffset, yOffset; /**< Offset for the visible portion of the character in pixels. */
  19. INT32 xAdvance, yAdvance; /**< Determines how much to advance the pen after writing this character, in pixels. */
  20. };
  21. /**
  22. * @brief Interop class between C++ & CLR for FontBitmap.
  23. */
  24. class BS_SCR_BE_EXPORT ScriptFontBitmap : public ScriptObject<ScriptFontBitmap>
  25. {
  26. public:
  27. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "FontBitmap")
  28. /**
  29. * @brief Creates a new managed instance of a font bitmap.
  30. *
  31. * @param bitmap Native font bitmap to initialize the managed instance with.
  32. */
  33. static MonoObject* create(SPtr<const FontBitmap> bitmap);
  34. private:
  35. friend class ScriptResourceManager;
  36. ScriptFontBitmap(MonoObject* instance, SPtr<const FontBitmap> bitmap);
  37. /**
  38. * @brief Converts the native character description into a script character description.
  39. */
  40. static ScriptCharDesc convertCharDesc(const CHAR_DESC& desc);
  41. SPtr<const FontBitmap> mBitmap;
  42. /************************************************************************/
  43. /* CLR HOOKS */
  44. /************************************************************************/
  45. static UINT32 internal_GetSize(ScriptFontBitmap* instance);
  46. static INT32 internal_GetBaselineOffset(ScriptFontBitmap* instance);
  47. static UINT32 internal_GetLineHeight(ScriptFontBitmap* instance);
  48. static UINT32 internal_GetSpaceWidth(ScriptFontBitmap* instance);
  49. static void internal_GetMissingChar(ScriptFontBitmap* instance, ScriptCharDesc* output);
  50. static MonoArray* internal_GetPages(ScriptFontBitmap* instance);
  51. static void internal_GetChar(ScriptFontBitmap* instance, UINT32 id, ScriptCharDesc* output);
  52. static MonoArray* internal_GetKerning(ScriptFontBitmap* instance, UINT32 id);
  53. };
  54. /**
  55. * @brief Interop class between C++ & CLR for KerningPair.
  56. */
  57. class BS_SCR_BE_EXPORT ScriptKerningPair : public ScriptObject <ScriptKerningPair>
  58. {
  59. public:
  60. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "KerningPair")
  61. private:
  62. ScriptKerningPair(MonoObject* instance);
  63. };
  64. }