diff --git a/src/BitmapText.cpp b/src/BitmapText.cpp index 15d0e369cf..fa78d2c777 100644 --- a/src/BitmapText.cpp +++ b/src/BitmapText.cpp @@ -1435,6 +1435,23 @@ ColorBitmapText::SetMaxLines(int iNumLines, int iDirection) class LunaBitmapText : public Luna { public: + static int getGlyphRect(T* p, lua_State* L) + { + int idx = (IArg(1) - 1) * 4; // lua idx start at 1 and 4 verts per glyph + if (idx < 0 || idx >= p->m_aVertices.size()) { + lua_pushnil(L); + return 1; + } + for (int i = 0; i < 4; i++) { + lua_newtable(L); + auto& v = p->m_aVertices[idx + i].p; + lua_pushnumber(L, v.x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, v.y); + lua_rawseti(L, -2, 2); + } + return 4; + } static int wrapwidthpixels(T* p, lua_State* L) { p->SetWrapWidthPixels(IArg(1)); @@ -1541,6 +1558,7 @@ class LunaBitmapText : public Luna LunaBitmapText() { + ADD_METHOD(getGlyphRect); ADD_METHOD(wrapwidthpixels); ADD_METHOD(maxwidth); ADD_METHOD(maxheight); diff --git a/src/BitmapText.h b/src/BitmapText.h index a003c88149..c53d01691d 100644 --- a/src/BitmapText.h +++ b/src/BitmapText.h @@ -146,6 +146,8 @@ class BitmapText : public Actor // Commands void PushSelf(lua_State* L) override; + vector m_aVertices; + protected: Font* m_pFont; bool m_bUppercase; @@ -163,8 +165,6 @@ class BitmapText : public Actor float m_fDistortion; int m_iVertSpacing; - vector m_aVertices; - vector m_vpFontPageTextures; map m_mAttributes; bool m_bHasGlowAttribute;