Search code examples
windows-phone-7xnatruetype

Windows Phone 7 - How to use TTF in SpriteFont?


Is there any way to use custom fonts in XNA?


Solution

  • Sure, you need to import the font to your system. Add the font to the font system catalog or add through control panel. When it is ready (reboot Visual Studio) use the custom template for SpriteFont in Visual studio, which generates an XML file. An exmaple:

    <?xml version="1.0" encoding="utf-8"?>
    <!--
    This file contains an xml description of a font, and will be read by the XNA
    Framework Content Pipeline. Follow the comments to customize the appearance
    of the font in your game, and to change the characters which are available to draw
    with.
    -->
    <XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
      <Asset Type="Graphics:FontDescription">
    
        <!--
        Modify this string to change the font that will be imported.
        -->
        <FontName>Moire</FontName>
    ...