internal static void DrawText(GUIGeometryBuffer geometryBuffer, Font font, Vector2 position, String text, Color color)
{
for(var i = 0; i < text.Length; i++)
{
char c = text[i];
Glyph glyph;
if (!glyphManager.TryGetGlyphInfo(font, c, out glyph))
{
Log.Warn("Glyph not found for character " + c);
continue;
}
SubTexture subTexture;
ResourceHandle<Material> material;
if (glyphManager.TryGetGlyphImage(font, c, out subTexture, out material))
{
var renderRect = new RectangleF(
position.X + glyph.XOffset,
position.Y + glyph.BaseLineOffset,
glyph.Width,
glyph.Height);
geometryBuffer.AddRectangle(renderRect,
subTexture.LeftTopUV, subTexture.RightTopUV,
subTexture.RightBottomUV, subTexture.LeftBottomUV,
material, color);
}
if (i < text.Length-1){
var kern = glyphManager.GetKerning(font, text[i], text[i+1]);
position.X += glyph.Advance + kern.X;
position.Y += kern.Y;
}
}
}