diff options
author | chai <chaifix@163.com> | 2021-11-05 14:25:39 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-05 14:25:39 +0800 |
commit | 2b9621a46288532b352b7838f96aca80f971e3d1 (patch) | |
tree | 6131ef5484e4f6d4c14c541b65a107869e3b112e /Runtime/Scripting/GUI | |
parent | 6d5787d8da9ad1685864668dd4c3d6aa73a563db (diff) |
*misc
Diffstat (limited to 'Runtime/Scripting/GUI')
-rw-r--r-- | Runtime/Scripting/GUI/Font.bind.cpp | 91 |
1 files changed, 1 insertions, 90 deletions
diff --git a/Runtime/Scripting/GUI/Font.bind.cpp b/Runtime/Scripting/GUI/Font.bind.cpp index 0570df0..8759fe1 100644 --- a/Runtime/Scripting/GUI/Font.bind.cpp +++ b/Runtime/Scripting/GUI/Font.bind.cpp @@ -10,19 +10,10 @@ #include "Runtime/GUI/TextMeshGenerator.h" #include "Runtime/Utilities/AutoInvoke.h" -static std::vector<character::Unicode>* s_Codepoints;
-
-InitializeStaticVariables([](){
- s_Codepoints = new std::vector<character::Unicode>();
-});
-
LUA_BIND_REGISTRY(Font) { LUA_BIND_REGISTER_METHODS(state, - { "New", _New }, - { "GetCharacter", _GetCharacter }, - { "GetCharacters", _GetCharacters }, - { "GetGlyphAtlas", _GetGlyphAtlas } + { "New", _New } ); } @@ -83,83 +74,3 @@ LUA_BIND_IMPL_METHOD(Font, _New) return 1;
}
-
-// font:GetCharacter(char, size, encoding)
-LUA_BIND_IMPL_METHOD(Font, _GetCharacter) -{
- LUA_BIND_PREPARE(L, Font);
- return 1;
-}
-
-// font:GetCharacter(str, size, wordwrap, preferredWidth, encoding)
-LUA_BIND_IMPL_METHOD(Font, _GetCharacters) -{
- LUA_BIND_PREPARE(L, Font);
- //LUA_BIND_CHECK(L, "US");
-
- char* buf = (char*)state.GetValue<const char*>(2, "");
- int size = state.GetValue<int>(3, 12);
- bool wordwrap = state.GetValue<bool>(4, false);
- float preferred = state.GetValue<float>(5, 0);
- int encoding = state.GetValue<int>(6, EEncoding::Encoding_UTF8);
-
- s_Codepoints->clear();
- InvokeWhenLeave([]() {
- s_Codepoints->clear();
- });
-
- if (encoding == EEncoding::Encoding_UTF8)
- {
- while (*buf != 0) {
- int err;
- s_Codepoints->push_back(utf8::getu8c(&buf, &err));
- if (err != 0)
- {
- log_warning("Illegal utf8 bytes %d", err);
- }
- }
- }
- else if (encoding == EEncoding::Encoding_UTF16)
- {
- while (*buf != 0) {
- unsigned short* s = (unsigned short*)(buf);
- s_Codepoints->push_back(*s);
- buf += 2;
- }
- }
- else if (encoding == EEncoding::Encoding_ASCII)
- {
- while (*buf != 0) {
- s_Codepoints->push_back(*buf);
- buf += 1;
- }
- }
-
- self->RenderCharacters(*s_Codepoints, size);
-
- UnicodeString str;
- str.str = s_Codepoints->data();
- str.length = s_Codepoints->size();
-
- WipeGLError();
-
- const UITextMesh* tm = g_TextMeshGenerator.GetTextMesh(str, self, size, size + 3, Color32::white, TextAnchor_UpperLeft, TextAlignment_Left, wordwrap, preferred);
- tm->Draw();
-
- return 0;
-}
-
-// font:GetAtlas(i)
-// return lightuserdata
-LUA_BIND_IMPL_METHOD(Font, _GetGlyphAtlas) -{
- LUA_BIND_PREPARE(L, Font);
- //LUA_BIND_CHECK(L, "UN");
-
- //int i = state.GetValue<int>(2, 0);
- //GlyphAtals atlas = self->m_Atlases[i];
-
- //state.Push((const void*)atlas.altas);
-
- return 1;
-}
\ No newline at end of file |