From 1e9bdd854c89c32fa09016871d9693976fc9a08b Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 8 Oct 2018 20:10:35 +0800 Subject: =?UTF-8?q?*=E5=A2=9E=E5=8A=A0=E7=9B=B4=E6=8E=A5=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/modules/graphics/font.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/lua/modules/graphics/font.cpp') diff --git a/src/lua/modules/graphics/font.cpp b/src/lua/modules/graphics/font.cpp index 15aa04e..0b0e1a0 100644 --- a/src/lua/modules/graphics/font.cpp +++ b/src/lua/modules/graphics/font.cpp @@ -37,11 +37,27 @@ namespace lua { Proxy* pFont = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_FONT); Font* font = pFont->getObject(); - Proxy* p = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_PAGE); - Page* page = p->getObject(); - int x = luax_checkinteger(L, 3); - int y = luax_checkinteger(L, 4); - font->print(page, x, y); + if (luax_istype(L, 2, JIN_GRAPHICS_PAGE)) + { + Proxy* p = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_PAGE); + Page* page = p->getObject(); + int x = luax_checkinteger(L, 3); + int y = luax_checkinteger(L, 4); + font->print(page, x, y); + } + else if (luax_isstring(L, 2)) + { + const char* text = luax_checkstring(L, 2); + int x = luax_checkinteger(L, 3); + int y = luax_checkinteger(L, 4); + int lh = luax_checkinteger(L, 5); + int sp = luax_checkinteger(L, 6); + font->print(text, x, y, lh, sp); + } + else + { + luax_typerror(L, 2, "font or string"); + } return 0; } -- cgit v1.1-26-g67d0