#pragma once #include "BsScriptEnginePrerequisites.h" #include "BsScriptResource.h" #include "BsScriptObject.h" #include "BsFont.h" namespace BansheeEngine { /** * @brief Describes a single character in a font of a specific size. */ struct ScriptCharDesc // Note: Must match C# struct CharDesc { UINT32 charId; /**< Character ID, corresponding to a Unicode key. */ UINT32 page; /**< Index of the texture the character is located on. */ float uvX, uvY; /**< Texture coordinates of the character in the page texture. */ float uvWidth, uvHeight; /**< Width/height of the character in texture coordinates. */ UINT32 width, height; /**< Width/height of the character in pixels. */ INT32 xOffset, yOffset; /**< Offset for the visible portion of the character in pixels. */ INT32 xAdvance, yAdvance; /**< Determines how much to advance the pen after writing this character, in pixels. */ }; /** * @brief Interop class between C++ & CLR for FontBitmap. */ class BS_SCR_BE_EXPORT ScriptFontBitmap : public ScriptObject { public: SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "FontBitmap") /** * @brief Creates a new managed instance of a font bitmap. * * @param bitmap Native font bitmap to initialize the managed instance with. */ static MonoObject* create(SPtr bitmap); private: friend class ScriptResourceManager; ScriptFontBitmap(MonoObject* instance, SPtr bitmap); /** * @brief Converts the native character description into a script character description. */ static ScriptCharDesc convertCharDesc(const CHAR_DESC& desc); SPtr mBitmap; /************************************************************************/ /* CLR HOOKS */ /************************************************************************/ static UINT32 internal_GetSize(ScriptFontBitmap* instance); static INT32 internal_GetBaselineOffset(ScriptFontBitmap* instance); static UINT32 internal_GetLineHeight(ScriptFontBitmap* instance); static UINT32 internal_GetSpaceWidth(ScriptFontBitmap* instance); static void internal_GetMissingChar(ScriptFontBitmap* instance, ScriptCharDesc* output); static MonoArray* internal_GetPages(ScriptFontBitmap* instance); static void internal_GetChar(ScriptFontBitmap* instance, UINT32 id, ScriptCharDesc* output); static MonoArray* internal_GetKerning(ScriptFontBitmap* instance, UINT32 id); }; /** * @brief Interop class between C++ & CLR for KerningPair. */ class BS_SCR_BE_EXPORT ScriptKerningPair : public ScriptObject { public: SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "KerningPair") private: ScriptKerningPair(MonoObject* instance); }; }