Export (0) Print
Expand All

SpriteFont Class

Represents a font texture.

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

public sealed 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 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.

Bb464165.note(en-us,XNAGameStudio.41).gifNote
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 7, Windows Vista, Windows XP

Community Additions

ADD
Show:
© 2014 Microsoft