public static TextureFont Load(XElement fontDefinition, ContentManager contentManager) { TextureFont font = new TextureFont(); foreach (XElement entry in fontDefinition.Elements("Entry")) font.textures.Add(entry.Attribute("Character").Value, contentManager.Load<Texture2D>(entry.Value)); return font; }
public static void DrawString(this SpriteBatch spriteBatch, TextureFont font, string str, Vector2 location, Color tinting) { Vector2 currentLocation = location; for (int character = 0; character < str.Length; character++) { string piece = str.Substring(character, 1); spriteBatch.Draw(font.GetTexture(piece), currentLocation, tinting); currentLocation.X += font.GetTexture(piece).Width; } }
public static void DrawString(this SpriteBatch spriteBatch, TextureFont font, string str, Vector2 location, Color tinting, float opacity) { spriteBatch.DrawString(font, str, location, new Color(tinting, opacity)); }