Closed SC5Shout closed 6 years ago
Hi! I want to render some text using vera font included to demos. There is a problem with T letter
There should be Total...
Total...
Demo - distance-field-2 works perfectly fine. I am adding vertices and elements similary from this demo.
void RenderData::DrawString(const std::string& text, const Vector2& position, uint color, float scale, Font& font) { using namespace ftgl; texture_font_t* ftFont = font.getFTFont(); float texture = font.getTexture(), x = position.x; for (uint i = 0; i < text.length(); ++i) { texture_glyph_t* glyph = texture_font_get_glyph(ftFont, text.c_str() + i); if (glyph) { if (i > 0) { float kerning = texture_glyph_get_kerning(glyph, text.c_str() + i - 1); x += kerning; } float x0 = x + glyph->offset_x * scale, y0 = position.y + glyph->offset_y * scale, x1 = x0 + glyph->width * scale, y1 = y0 - glyph->height * scale, u0 = glyph->s0, v0 = glyph->t0, u1 = glyph->s1, v1 = glyph->t1; AddVertexData(Vector2(x0, y0), Vector2(u0, v0), color, texture); AddVertexData(Vector2(x0, y1), Vector2(u0, v1), color, texture); AddVertexData(Vector2(x1, y1), Vector2(u1, v1), color, texture); AddVertexData(Vector2(x1, y0), Vector2(u1, v0), color, texture); AddRectElements(); x += glyph->advance_x * scale; } } }
How can I fix T positioning?
T
I did not know that I have to scale kerning too. It works perfectly fine when I scaled kerning.
Hi! I want to render some text using vera font included to demos. There is a problem with T letter
There should be
Total...
Demo - distance-field-2 works perfectly fine. I am adding vertices and elements similary from this demo.
How can I fix
T
positioning?