创建spriteFont的xnb资源文件

字体的xnb文件是由spriteFont(xml)文件使用XNA编译之后得到.其实很简单只是需求比较多.

  1. 下载http://xnacontentcompiler.codeplex.com/这个项目,可以将.sprintFont文件编译为xnb.
  2. 这个项目需要XNA 4.0的支持, 而安装XNA 4.0需要先安装vs2010 C#.

如果上面都已经做好,之后的步骤就非常简单.

  1. 创建一个.spriteFont文件,内容如下:
    <?xml version='1.0' encoding='utf-8'?>
    <XnaContent xmlns:Graphics='Microsoft.Xna.Framework.Content.Pipeline.Graphics'>
          <Asset Type='Graphics:FontDescription'>
               <FontName>Courier New</FontName>
               <Size>32</Size>
               <Spacing>2</Spacing>
               <Style>Bold</Style>
               <CharacterRegions>
                     <CharacterRegion>
                          <Start>&#32;</Start>
                          <End>&#126;</End>
                     </CharacterRegion>
               </CharacterRegions>
          </Asset>
    </XnaContent>


  2. 使用下载的项目它.spriteFont文件编译为.xnb文件.


PS: MSDN中对 .spriteFont 文件字段的说明,http://msdn.microsoft.com/en-us/library/bb447759.aspx(文档中的sample中的CharacterRegion节点是错误的).

你可能感兴趣的:(spriteFont,MonoGame,xnb)