aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Font
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Graphics/Font')
-rw-r--r--src/libjin/Graphics/Font/je_font.h2
-rw-r--r--src/libjin/Graphics/Font/je_page.h2
-rw-r--r--src/libjin/Graphics/Font/je_texture_font.cpp29
-rw-r--r--src/libjin/Graphics/Font/je_ttf.cpp11
-rw-r--r--src/libjin/Graphics/Font/je_ttf.h4
5 files changed, 35 insertions, 13 deletions
diff --git a/src/libjin/Graphics/Font/je_font.h b/src/libjin/Graphics/Font/je_font.h
index 75dd4c5..4529902 100644
--- a/src/libjin/Graphics/Font/je_font.h
+++ b/src/libjin/Graphics/Font/je_font.h
@@ -97,4 +97,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif \ No newline at end of file
+#endif // __JE_FONT_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Font/je_page.h b/src/libjin/Graphics/Font/je_page.h
index 7df2784..fbc297e 100644
--- a/src/libjin/Graphics/Font/je_page.h
+++ b/src/libjin/Graphics/Font/je_page.h
@@ -48,4 +48,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif \ No newline at end of file
+#endif // __JE_PAGE_H \ No newline at end of file
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;
}
diff --git a/src/libjin/Graphics/Font/je_ttf.cpp b/src/libjin/Graphics/Font/je_ttf.cpp
index 0ee02ab..a11efb0 100644
--- a/src/libjin/Graphics/Font/je_ttf.cpp
+++ b/src/libjin/Graphics/Font/je_ttf.cpp
@@ -1,5 +1,5 @@
#include "../../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include <stdio.h>
@@ -279,6 +279,13 @@ namespace JinEngine
p.x = 0;
continue;
}
+ if (c == 0x09)
+ {
+ // tab = 4*space
+ unsigned cw = getCharWidth(0x20);
+ p.x += cw * 4;
+ continue;
+ }
glyphlize(c);
p.x += glyph->width + spacing;
i += 4;
@@ -453,4 +460,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
+#endif // defined(jin_graphics) \ No newline at end of file
diff --git a/src/libjin/Graphics/Font/je_ttf.h b/src/libjin/Graphics/Font/je_ttf.h
index 9acb07e..7bc6934 100644
--- a/src/libjin/Graphics/Font/je_ttf.h
+++ b/src/libjin/Graphics/Font/je_ttf.h
@@ -1,7 +1,7 @@
#ifndef __JETTF_H
#define __JE_TTF_H
#include "../../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include <vector>
#include <map>
@@ -283,6 +283,6 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER
+#endif // defined(jin_graphics)
#endif // __JE_FONT_H \ No newline at end of file