Log in Page Discussion History Go to the site toolbox


From BluWiki


by Benjamin Hale

Part of a series of XNA Tutorials.

To begin using spritefonts, one must add a spritefont reference to the project.

  • Right-click the "Content" in the solution explorer.
  • Spritefont add.PNG
  • Add...
    • New Item...
    • Select the "Visual C#" category
    • Choose "Sprite Font" and give it a name.

This creates an XML file delineating a font.

  • Spritefont text.PNG

Example spritefont file without documentation:

<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
  <Asset Type="Graphics:FontDescription">
          <Start> </Start>


  • FontName: The name of the font one wishes to use.
  • Size: The size one wishes, in points.
  • Spacing: Spacing between letters, in pixels.
  • UseKerning: Kerning or no?
  • Style: Bold, italic, regular.
  • CharacterRegions
    • CharacterRegion: Which range of characters one wishes to use; inclusive.
      • Start: Beginning character; HTML character entity.
      • End: Ending character; HTML character entity.


One can use scaling while drawing strings to simulate different-size fonts, but this detracts from quality; going from a smaller size to a larger makes the string blocky, and going from a larger size to a smaller produces resolutio artifacts.


Microsoft, MSDN Library, January 2009

Site Toolbox:

Personal tools
GNU Free Documentation License 1.2
This page was last modified on 10 September 2009, at 18:42.
Disclaimers - About BluWiki