public static void RenderText( String text, float X, float Y, float wrapAt, Renderer.RenderContext2D context, BitmapFont font, float depth = 0) { context.Texture = font.fontData; var x = X; var y = Y; var kx = (font.glypthWidth - font.kerningWidth) / 2; int col = (int)font.fontData.Width / (int)font.glypthWidth; for (var i = 0; i < text.Length; ++i) { if (x >= wrapAt) { y += font.glypthHeight; x = X; } var code = text[i]; if (code == '\n') { x = X; y += font.glypthHeight; } else if (code == ' ') { x += font.kerningWidth; } else if (code < 0x80) { //code -= (char)0x20; float fx = (code % col) * font.glypthWidth; float fy = (code / col) * font.glypthHeight; context.Glyph(x, y, font.glypthWidth, font.glypthHeight, fx / font.fontData.Width, fy / font.fontData.Height, font.glypthWidth / font.fontData.Width, font.glypthHeight / font.fontData.Height, depth); //context.Quad(X, Y, font.glypthWidth, font.glypthHeight, fx, fy, font.glypthWidth, font.glyphHeight x += font.kerningWidth; } } }