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/libjin/Graphics/Font.cpp | 6 ------ src/libjin/Graphics/Font.h | 1 - src/lua/modules/graphics/font.cpp | 26 +++++++++++++++++++++----- 3 files changed, 21 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/libjin/Graphics/Font.cpp b/src/libjin/Graphics/Font.cpp index 77d48f7..3e18359 100644 --- a/src/libjin/Graphics/Font.cpp +++ b/src/libjin/Graphics/Font.cpp @@ -65,12 +65,6 @@ namespace graphics return font; } - void Font::destroyFont(Font* font) - { - if (font != nullptr) - delete font; - } - Font::Font(FontData* f, unsigned int fontSize) : cursor(0, 0) , font(f) diff --git a/src/libjin/Graphics/Font.h b/src/libjin/Graphics/Font.h index 2bd51a5..0cb07de 100644 --- a/src/libjin/Graphics/Font.h +++ b/src/libjin/Graphics/Font.h @@ -53,7 +53,6 @@ namespace graphics typedef unsigned int Codepoint; static Font* createFont(FontData* fontData, unsigned int fontSzie); - static void destroyFont(Font* font); Page* typeset(const char* text, int lineheight, int spacing); void print(const char* text, int x, int y, int lineheight, int spacing = 0); 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