float TextDraw::RenderCharacter( const Font & font, char c, float x, float y, float scalex, float scaley, VertexArray & output_array) { const Font::CharInfo * ci = 0; if (!font.GetCharInfo(c, ci)) return 0; float invsize = font.GetInvSize(); float x1 = x + ci->xoffset * invsize * scalex; float x2 = x1 + ci->width * invsize * scalex; float y1 = y - ci->yoffset * invsize * scaley; float y2 = y1 + ci->height * invsize * scaley; float u1 = ci->x; float u2 = u1 + ci->width; float v1 = ci->y; float v2 = v1 + ci->height; float v[] = {x1, y1, 0, x2, y1, 0, x2, y2, 0, x1, y2, 0}; float t[] = {u1, v1, u2, v1, u2, v2, u1, v2}; int f[] = {0, 1, 2, 0, 2, 3}; if (output_array.GetTexCoordSets() == 0) { output_array.SetFaces(f, 6); output_array.SetVertices(v, 12); output_array.SetTexCoordSets(1); output_array.SetTexCoords(0, t, 8); } else { float * n = 0; output_array.Add(0, 0, n, 0, v, 12, f, 6, t, 8); } return ci->xadvance * invsize * scalex; }