BsScriptFontBitmap.h 2.9 KB

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