/// <summary> /// Writes a text on the screen. /// </summary> /// <param name="font">A font.</param> /// <param name="text">The text</param> /// <param name="position">The position of the text-handle on screen</param> /// <param name="relativeHandle">The text-handle</param> /// <param name="color">The color of the text.</param> /// <param name="UI">Is this Text part of the UI? (default is true)</param> public void DrawText(Assets.Font font, string text, Vector2 position, Handle relativeHandle, Color color, bool UI = true) { if (active) { //Nullcheck for the font. if (font == null) font = Settings.DefaultFont; if (UI) { base.End(); base.Begin(); } Vector2 handleOffset = -font.GetHandleOffset(relativeHandle, text); int charoffset = (int)handleOffset.X; int heightoffset = (int)handleOffset.Y; for (int i = 0; i < text.Length; i++) { base.Draw(font[text[i]], position + Vector2.UnitX * charoffset + Vector2.UnitY * heightoffset, color); charoffset += font[text[i]].Width; } } }