SpriteFont font = Content.Load("Arial"); string text = "Hello World!"; Vector2 position = new Vector2(100, 100); Color color = Color.White; spriteBatch.DrawString(font, text, position, color);
SpriteFont font = new SpriteFont(graphicsDevice, "Arial", 24);Here, a new SpriteFont is created with the Arial font and a size of 24. The graphics device is passed as a parameter, which is required for creating a new SpriteFont. Overall, the Microsoft.Xna.Framework.Graphics SpriteFont is a useful class for rendering text in XNA or MonoGame applications. It allows for customization of the font and size, and can be used with the SpriteBatch.DrawString method to display text on the screen.