aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/graphics/fonts/je_ttf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/graphics/fonts/je_ttf.cpp')
-rw-r--r--src/libjin/graphics/fonts/je_ttf.cpp76
1 files changed, 38 insertions, 38 deletions
diff --git a/src/libjin/graphics/fonts/je_ttf.cpp b/src/libjin/graphics/fonts/je_ttf.cpp
index 904617a..5d341fa 100644
--- a/src/libjin/graphics/fonts/je_ttf.cpp
+++ b/src/libjin/graphics/fonts/je_ttf.cpp
@@ -233,30 +233,30 @@ namespace JinEngine
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;\
- glyphvertices.push_back(vertex);
-
-#define glyphlize(c)\
- do{\
- glyph = &findGlyph(c); \
- if (texture != glyph->atlas) \
- { \
- GlyphArrayDrawInfo info; \
- info.start = i; \
- info.count = 0; \
- info.texture = glyph->atlas; \
- texture = glyph->atlas; \
- glyphinfolist.push_back(info); \
- } \
- glyphinfolist[glyphinfolist.size() - 1].count += 4; \
- TTFGlyph::Bbox& bbox = glyph->bbox; \
- glyphvertices_push(p.x, p.y, bbox.x, bbox.y); \
- glyphvertices_push(p.x, p.y + glyph->height, bbox.x, bbox.y + bbox.h); \
- glyphvertices_push(p.x + glyph->width, p.y + glyph->height, bbox.x + bbox.w, bbox.y + bbox.h); \
- glyphvertices_push(p.x + glyph->width, p.y, bbox.x + bbox.w, bbox.y); \
- }while(0)
+ #define glyphvertices_push(_x, _y, _u, _v) \
+ vertex.x = _x; vertex.y = _y;\
+ vertex.u = _u; vertex.v = _v;\
+ glyphvertices.push_back(vertex);
+
+ #define glyphlize(c)\
+ do{\
+ glyph = &findGlyph(c); \
+ if (texture != glyph->atlas) \
+ { \
+ GlyphArrayDrawInfo info; \
+ info.start = i; \
+ info.count = 0; \
+ info.texture = glyph->atlas; \
+ texture = glyph->atlas; \
+ glyphinfolist.push_back(info); \
+ } \
+ glyphinfolist[glyphinfolist.size() - 1].count += 4; \
+ TTFGlyph::Bbox& bbox = glyph->bbox; \
+ glyphvertices_push(p.x(), p.y(), bbox.x, bbox.y); \
+ glyphvertices_push(p.x(), p.y() + glyph->height, bbox.x, bbox.y + bbox.h); \
+ glyphvertices_push(p.x() + glyph->width, p.y() + glyph->height, bbox.x + bbox.w, bbox.y + bbox.h); \
+ glyphvertices_push(p.x() + glyph->width, p.y(), bbox.x + bbox.w, bbox.y); \
+ }while(0)
for (Codepoint c : text)
{
@@ -265,22 +265,22 @@ namespace JinEngine
if (c == 0x0A)
{
/* new line */
- p.y += lineheight;
- p.x = 0;
+ p.y() += lineheight;
+ p.x() = 0;
continue;
}
if (c == 0x09)
{
// tab = 4*space
unsigned cw = getCharWidth(0x20);
- p.x += cw * 4;
+ p.x() += cw * 4;
continue;
}
glyphlize(c);
- p.x += glyph->width + spacing;
+ p.x() += glyph->width + spacing;
i += 4;
}
- getTextBox(text, &page->size.w, &page->size.h, lineheight, spacing);
+ getTextBox(text, &page->size.w(), &page->size.h(), lineheight, spacing);
return page;
}
@@ -411,32 +411,32 @@ namespace JinEngine
/* bake glyph */
ttf->getHMetrics(character, &adw, &lsb);
ttf->popTTFsize();
- if (cursor.x + adw > textureWidth)
+ if (cursor.x() + adw > textureWidth)
{
- cursor.x = 0;
- cursor.y += descent;
- if (cursor.y + descent * 2 > textureHeight)
+ cursor.x() = 0;
+ cursor.y() += descent;
+ if (cursor.y() + descent * 2 > textureHeight)
{
/* create new atlas */
atlas = createAtlas();
- cursor.y = 0;
+ cursor.y() = 0;
}
}
gl.bindTexture(atlas);
- gl.texSubImage(cursor.x + xoff, cursor.y + yoff + baseline, w, h, GL_RGBA, GL_UNSIGNED_BYTE, bitmap);
+ gl.texSubImage(cursor.x() + xoff, cursor.y() + yoff + baseline, w, h, GL_RGBA, GL_UNSIGNED_BYTE, bitmap);
gl.bindTexture();
delete[] bitmap;
}
TTFGlyph glyph;
glyph.atlas = atlas;
- glyph.bbox.x = cursor.x / (float)textureWidth;
- glyph.bbox.y = cursor.y / (float)textureHeight;
+ glyph.bbox.x = cursor.x() / (float)textureWidth;
+ glyph.bbox.y = cursor.y() / (float)textureHeight;
glyph.bbox.w = adw / (float)textureWidth;
glyph.bbox.h = descent / (float)textureHeight;
glyph.width = adw;
glyph.height = descent;
glyphs.insert(std::pair<unsigned int, TTFGlyph>(character, glyph));
- cursor.x += adw;
+ cursor.x() += adw;
return glyphs[character];
}