aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-15 12:58:40 +0800
committerchai <chaifix@163.com>2018-10-15 12:58:40 +0800
commit252e074c41a73312be3e235b07be266a9aee59fb (patch)
tree51e659073235df737a592fa2fd04baf415cdf122 /src
parent3154c69a341028e88007b9883f438f75e0a5ff55 (diff)
*格式化代码
Diffstat (limited to 'src')
-rw-r--r--src/libjin/Graphics/Font/TTF.cpp23
-rw-r--r--src/lua/modules/graphics/graphics.cpp36
2 files changed, 30 insertions, 29 deletions
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)