summaryrefslogtreecommitdiff
path: root/Runtime/Scripting/GUI
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Scripting/GUI')
-rw-r--r--Runtime/Scripting/GUI/Font.bind.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Runtime/Scripting/GUI/Font.bind.cpp b/Runtime/Scripting/GUI/Font.bind.cpp
index 7d7e3f2..0570df0 100644
--- a/Runtime/Scripting/GUI/Font.bind.cpp
+++ b/Runtime/Scripting/GUI/Font.bind.cpp
@@ -7,6 +7,8 @@
#include "Runtime/Utilities/StaticInitiator.h"
#include "Runtime/GUI/UITextMesh.h"
#include "Runtime/Math/Math.h"
+#include "Runtime/GUI/TextMeshGenerator.h"
+#include "Runtime/Utilities/AutoInvoke.h"
static std::vector<character::Unicode>* s_Codepoints;
@@ -102,6 +104,10 @@ LUA_BIND_IMPL_METHOD(Font, _GetCharacters)
int encoding = state.GetValue<int>(6, EEncoding::Encoding_UTF8);
s_Codepoints->clear();
+ InvokeWhenLeave([]() {
+ s_Codepoints->clear();
+ });
+
if (encoding == EEncoding::Encoding_UTF8)
{
while (*buf != 0) {
@@ -137,7 +143,7 @@ LUA_BIND_IMPL_METHOD(Font, _GetCharacters)
WipeGLError();
- UITextMesh* tm = new UITextMesh(str, self, size, size + 3, Color32::white, TextAnchor_UpperLeft, TextAlignment_Left, wordwrap, preferred);
+ const UITextMesh* tm = g_TextMeshGenerator.GetTextMesh(str, self, size, size + 3, Color32::white, TextAnchor_UpperLeft, TextAlignment_Left, wordwrap, preferred);
tm->Draw();
return 0;