From c23ff8369633962cb90b24c65389cea578f5a8e7 Mon Sep 17 00:00:00 2001 From: pixel Date: Thu, 24 Jan 2008 17:34:57 +0000 Subject: Adding unicode versions of ftgl calls. --- lib/LuaFTGL.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/LuaFTGL.cc b/lib/LuaFTGL.cc index b64040f..1833e5a 100644 --- a/lib/LuaFTGL.cc +++ b/lib/LuaFTGL.cc @@ -19,8 +19,11 @@ enum EncapFTFont_methods_t { FTFONT_DESCENDER, FTFONT_LINEHEIGHT, FTFONT_BBOX, + FTFONT_UBBOX, FTFONT_ADVANCE, + FTFONT_UADVANCE, FTFONT_RENDER, + FTFONT_URENDER, FTFONT_ERROR, }; @@ -44,8 +47,11 @@ struct lua_functypes_t EncapFTFont_methods[] = { { FTFONT_DESCENDER, "Descender", 0, 0, { } }, { FTFONT_LINEHEIGHT, "LineHeight", 0, 0, { } }, { FTFONT_BBOX, "BBox", 1, 1, { BLUA_STRING } }, + { FTFONT_UBBOX, "UBBox", 1, 1, { BLUA_STRING } }, { FTFONT_ADVANCE, "Advance", 1, 1, { BLUA_STRING } }, + { FTFONT_UADVANCE, "UAdvance", 1, 1, { BLUA_STRING } }, { FTFONT_RENDER, "Render", 1, 1, { BLUA_STRING } }, + { FTFONT_URENDER, "URender", 1, 1, { BLUA_STRING } }, { FTFONT_ERROR, "Error", 0, 0, { } }, { -1, 0, 0, 0, 0 } }; @@ -143,6 +149,7 @@ int sLua_EncapFTFont::EncapFTFont_proceed(Lua * L, int n, EncapFTFont * obj, int FTFont * f = obj->Get(); FT_Encoding * l; float llx, lly, llz, urx, ury, urz; + String x; switch (caller) { case FTFONT_CHARMAP: @@ -205,13 +212,36 @@ int sLua_EncapFTFont::EncapFTFont_proceed(Lua * L, int n, EncapFTFont * obj, int L->push(ury); L->push(urz); break; + case FTFONT_UBBOX: + r = 6; + x = L->tostring(2); + x.iconv("utf-8", "unicode"); + f->BBox((wchar_t *) x.to_charp(), llx, lly, llz, urx, ury, urz); + L->push(llx); + L->push(lly); + L->push(llz); + L->push(urx); + L->push(ury); + L->push(urz); + break; case FTFONT_ADVANCE: r = 1; L->push(f->Advance(L->tostring(2).to_charp())); break; + case FTFONT_UADVANCE: + r = 1; + x = L->tostring(2); + x.iconv("utf-8", "unicode"); + L->push(f->Advance((wchar_t *) x.to_charp())); + break; case FTFONT_RENDER: f->Render(L->tostring(2).to_charp()); break; + case FTFONT_URENDER: + x = L->tostring(2); + x.iconv("utf-8", "unicode"); + f->Render((wchar_t *) x.to_charp()); + break; case FTFONT_ERROR: r = 1; L->push((lua_Number) f->Error()); -- cgit v1.2.3