SpriteFont Class

Represents a font texture.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public class SpriteFont

To load a SpriteFont, click Sprite Font on the Add New Item menu. This adds an XML file to your project describing how to build a texture map for your font. At build time, XNA Game Studio Express creates a texture with the image of the characters of the font you specify, with the specified font point size.

At run time, load the font using ContentManager.Load, and pass it to SpriteBatch.DrawString when drawing text.

As with most types of software, font files are licensed rather than sold. Font licenses vary from vendor to vendor, but most don't allow redistribution of the fonts, and that includes redistribution of reproductions such as bitmaps containing the rasterized character set. This is even true of many of the licenses covering fonts that Microsoft supplies with applications and Windows. Be careful, therefore, to ensure that you have the required license rights to redistribute any font you include as a bitmap containing the rasterized character set in your game!

Xbox 360, Windows XP SP2, Windows Vista