diff options
author | chai <chaifix@163.com> | 2018-10-21 16:21:16 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-10-21 16:21:16 +0800 |
commit | 07770f3ad369ff47386310b731d349f7af1fe0d9 (patch) | |
tree | 7547b1a8b2beaceb31ea1b62edbdaa5cd6a1b247 /src/libjin/Graphics/Font/je_texture_font.cpp | |
parent | 066e5987c515dfc34537d73ca9d2a81ddd1f9e1b (diff) |
*修改编译控制
Diffstat (limited to 'src/libjin/Graphics/Font/je_texture_font.cpp')
-rw-r--r-- | src/libjin/Graphics/Font/je_texture_font.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/libjin/Graphics/Font/je_texture_font.cpp b/src/libjin/Graphics/Font/je_texture_font.cpp index 81ac343..f85a8ce 100644 --- a/src/libjin/Graphics/Font/je_texture_font.cpp +++ b/src/libjin/Graphics/Font/je_texture_font.cpp @@ -72,19 +72,27 @@ namespace JinEngine for (Codepoint c : text) { + // return if (c == 0x0D) continue; + // newline if (c == 0x0A) { - /* new line */ p.y += lineheight; p.x = 0; continue; } + if (c == 0x09) + { + // tab = 4*space + unsigned cw = getCharWidth(0x20); + p.x += cw * 4; + continue; + } glyph = findGlyph(c); if (glyph == nullptr) continue; - if (texture != this->texture) + if (texture != mTexture) { - texture = this->texture; + texture = mTexture; GlyphArrayDrawInfo info; info.start = i; info.count = 0; @@ -93,8 +101,8 @@ namespace JinEngine } glyphinfolist[glyphinfolist.size() - 1].count += 4; // normalized - float nx = glyph->x / (float)size.w, ny = glyph->y / (float)size.h; - float nw = glyph->w / (float)size.w, nh = glyph->h / (float)size.h; + float nx = glyph->x / (float)mSize.w, ny = glyph->y / (float)mSize.h; + float nw = glyph->w / (float)mSize.w, nh = glyph->h / (float)mSize.h; glyphvertices_push(p.x, p.y, nx, ny); glyphvertices_push(p.x, p.y + glyph->h, nx, ny + nh); glyphvertices_push(p.x + glyph->w, p.y + glyph->h, nx + nw, ny + nh); @@ -139,9 +147,16 @@ namespace JinEngine tmp = 0; continue; } + if (c == 0x09) + { + // tab = 4*space + unsigned cw = getCharWidth(0x20); + tmp += cw * 4; + if (tmp > res) res = tmp; + continue; + } tmp += getCharWidth(c) + spacing; - if (tmp > res) - res = tmp; + if (tmp > res) res = tmp; } return res; } |