public void DrawText(string _text, Vector2 position, float size, Color color, int shadowOffset = 2, bool centerVertical = false, bool centerHorizontal = false)
{
string text = CheckLetters(_text);
//scale the font with respect to the resolution
//the pt measure uses the width of the letter m so we only need the withd factor for scaling
size *= resolutionFactor;
int mipLevel = 0;
while (size < 0.5f && mipLevel < 3)
{
size *= 2f;
++mipLevel;
}
if (centerVertical || centerHorizontal)
{
var dimensions = MipFont[mipLevel].MeasureString(text);
if (centerHorizontal)
position.X -= (int)Math.Round(size * (float)dimensions.X / 2f);
if (centerVertical)
position.Y -= (int)Math.Round(size * (float)dimensions.Y / 2f);
}
if (shadowOffset > 0)
{
SpriteBatch.DrawString(MipFont[mipLevel], text, position + new Vector2(shadowOffset),
new Color(Color.Black, (color.A/255f) * 0.5f), 0, Vector2.Zero, size, SpriteEffects.None, 0);
}
SpriteBatch.DrawString(MipFont[mipLevel], text, position, color, 0, Vector2.Zero, size, SpriteEffects.None, 0);
}