aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/graphics/fonts
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/graphics/fonts')
-rw-r--r--src/libjin/graphics/fonts/je_texture_font.cpp26
-rw-r--r--src/libjin/graphics/fonts/je_ttf.cpp76
2 files changed, 51 insertions, 51 deletions
diff --git a/src/libjin/graphics/fonts/je_texture_font.cpp b/src/libjin/graphics/fonts/je_texture_font.cpp
index 7737f90..97f1f2f 100644
--- a/src/libjin/graphics/fonts/je_texture_font.cpp
+++ b/src/libjin/graphics/fonts/je_texture_font.cpp
@@ -25,15 +25,15 @@ namespace JinEngine
Vector2<int> count(bitmap->getWidth() / cellw, bitmap->getHeight() / cellh);
glyph.w = cellw;
glyph.h = cellh;
- for (int y = 0; y < count.row; ++y)
+ for (int y = 0; y < count.row(); ++y)
{
glyph.y = y * cellh;
- for (int x = 0; x < count.colum; ++x)
+ for (int x = 0; x < count.colum(); ++x)
{
glyph.x = x * cellw;
- if (x + y * count.colum >= codepoints.size())
+ if (x + y * count.colum() >= codepoints.size())
return;
- glyphs.insert(std::pair<Codepoint, TextureGlyph>(codepoints[x + y * count.colum], glyph));
+ glyphs.insert(std::pair<Codepoint, TextureGlyph>(codepoints[x + y * count.colum()], glyph));
}
}
}
@@ -135,15 +135,15 @@ namespace JinEngine
// newline
if (c == 0x0A)
{
- 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;
}
glyph = findGlyph(c);
@@ -162,14 +162,14 @@ namespace JinEngine
float w = getWidth(), h = getHeight();
float nx = glyph->x / w, ny = glyph->y / h;
float nw = glyph->w / w, nh = glyph->h / 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);
- glyphvertices_push(p.x + glyph->w, p.y, nx + nw, ny);
- p.x += glyph->w + spacing;
+ 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);
+ glyphvertices_push(p.x() + glyph->w, p.y(), nx + nw, ny);
+ p.x() += glyph->w + 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;
}
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];
}