diff options
author | chai <chaifix@163.com> | 2018-10-15 12:58:40 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-10-15 12:58:40 +0800 |
commit | 252e074c41a73312be3e235b07be266a9aee59fb (patch) | |
tree | 51e659073235df737a592fa2fd04baf415cdf122 | |
parent | 3154c69a341028e88007b9883f438f75e0a5ff55 (diff) |
*格式化代码
-rw-r--r-- | bin/Jin.exe | bin | 628736 -> 628736 bytes | |||
-rw-r--r-- | bin/jin.exe | bin | 628736 -> 628736 bytes | |||
-rw-r--r-- | src/libjin/Graphics/Font/TTF.cpp | 23 | ||||
-rw-r--r-- | src/lua/modules/graphics/graphics.cpp | 36 |
4 files changed, 30 insertions, 29 deletions
diff --git a/bin/Jin.exe b/bin/Jin.exe Binary files differindex dacc9cc..c1fbb6f 100644 --- a/bin/Jin.exe +++ b/bin/Jin.exe diff --git a/bin/jin.exe b/bin/jin.exe Binary files differindex dacc9cc..c1fbb6f 100644 --- a/bin/jin.exe +++ b/bin/jin.exe diff --git a/src/libjin/Graphics/Font/TTF.cpp b/src/libjin/Graphics/Font/TTF.cpp index 0e70d70..edef8a8 100644 --- a/src/libjin/Graphics/Font/TTF.cpp +++ b/src/libjin/Graphics/Font/TTF.cpp @@ -229,6 +229,18 @@ namespace graphics delete page; } + Page* TTF::typeset(const Content& text, int lineheight, int spacing) + { + Page* page = new Page(); + page->font = this; + vector<GlyphArrayDrawInfo>& glyphinfolist = page->glyphinfolist; + vector<GlyphVertex>& glyphvertices = page->glyphvertices; + int texture = -1; + TTFGlyph* glyph = nullptr; + GlyphVertex vertex; + Vector2<int> p(0, 0); + int i = 0; + #define glyphvertices_push(_x, _y, _u, _v) \ vertex.x = _x; vertex.y = _y;\ vertex.u = _u; vertex.v = _v;\ @@ -254,17 +266,6 @@ namespace graphics glyphvertices_push(p.x + glyph->width, p.y, bbox.x + bbox.w, bbox.y); \ }while(0) - Page* TTF::typeset(const Content& text, int lineheight, int spacing) - { - Page* page = new Page(); - page->font = this; - vector<GlyphArrayDrawInfo>& glyphinfolist = page->glyphinfolist; - vector<GlyphVertex>& glyphvertices = page->glyphvertices; - int texture = -1; - TTFGlyph* glyph = nullptr; - GlyphVertex vertex; - Vector2<int> p(0, 0); - int i = 0; for (Codepoint c : text) { if (c == 0x0D) diff --git a/src/lua/modules/graphics/graphics.cpp b/src/lua/modules/graphics/graphics.cpp index 620c239..645ae4a 100644 --- a/src/lua/modules/graphics/graphics.cpp +++ b/src/lua/modules/graphics/graphics.cpp @@ -277,6 +277,24 @@ namespace lua font->print(page, x, y); } + /* print(string, x, y, lineheight, spacing) */ + /* need set font */ + static int l_print(lua_State* L) + { + Font* font = context.curFont; + if (font == nullptr) + return 0; + unsigned length; + const char* str = luax_checklstring(L, 1, &length); + Text text(Encode::UTF8, str, length); + int x = luax_optnumber(L, 2, 0); + int y = luax_optnumber(L, 3, 0); + int lineheight = luax_optnumber(L, 4, font->getFontSize()); + int spacing = luax_optnumber(L, 5, 0); + font->print(text, x, y, lineheight, spacing); + return 0; + } + static int l_draw(lua_State* L) { if (luax_istype(L, 1, JIN_GRAPHICS_TEXTURE)) @@ -337,24 +355,6 @@ namespace lua } } - /* print(string, x, y, lineheight, spacing) */ - /* need set font */ - static int l_print(lua_State* L) - { - Font* font = context.curFont; - if (font == nullptr) - return 0; - unsigned length; - const char* str = luax_checklstring(L, 1, &length); - Text text(Encode::UTF8, str, length); - int x = luax_optnumber(L, 2, 0); - int y = luax_optnumber(L, 3, 0); - int lineheight = luax_optnumber(L, 4, font->getFontSize()); - int spacing = luax_optnumber(L, 5, 0); - font->print(text, x, y, lineheight, spacing); - return 0; - } - static int l_setColor(lua_State* L) { if (luax_gettop(L) == 0) |