c# – 无法在XNA4中加载spriteFont

c# – 无法在XNA4中加载spriteFont,第1张

概述我和XNA一起玩耍,我来到了需要加载字体的部分.够简单吧? Font1 = Content.Load<SpriteFont>("Arial"); 是我用来加载字体的代码. <?xml version="1.0" encoding="utf-8"?><!--This file contains an xml description of a font, and will be read by t 我和XNA一起玩耍,我来到了需要加载字体的部分.够简单吧?
Font1 = Content.Load<SpriteFont>("Arial");

是我用来加载字体的代码.

<?xml version="1.0" enCoding="utf-8"?><!--This file contains an xml description of a Font,and will be read by the XNAFramework Content Pipeline. Follow the comments to customize the appearanceof the Font in your game,and to change the characters which are available to drawwith.--><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>Arial</Fontname>    <!--    Size is a float value,measured in points. Modify this value to change    the size of the Font.    -->    <Size>14</Size>    <!--    Spacing is a float value,measured in pixels. Modify this value to change    the amount of spacing in between characters.    -->    <Spacing>0</Spacing>    <!--    UseKerning controls the layout of the Font. If this value is true,kerning information    will be used when placing characters.    -->    <UseKerning>true</UseKerning>    <!--    Style controls the style of the Font. ValID entrIEs are "Regular","Bold","Italic",and "Bold,Italic",and are case sensitive.    -->    <Style>Regular</Style>    <!--    If you uncomment this line,the default character will be substituted if you draw    or measure text that contains characters which were not included in the Font.    -->    <!-- <DefaultCharacter>*</DefaultCharacter> -->    <!--    CharacterRegions control what letters are available in the Font. Every    character from Start to End will be built and made available for drawing. The    default range is from 32,(ASCII space),to 126,('~'),covering the basic Latin    character set. The characters are ordered according to the Unicode standard.    See the documentation for more information.    -->    <CharacterRegions>      <CharacterRegion>        <Start>&#32;</Start>        <End>&#126;</End>      </CharacterRegion>    </CharacterRegions>  </Asset></XnaContent>

是我正在使用的spriteFont文件.它位于Content / Arial.spriteFont.

无论我选择什么字体,它都无法加载该字体.

Error loading "Arial". file not found.
解决方法 您发布的代码看起来很好,只要您设置内容根目录(此行是默认模板的一部分):
Content.RootDirectory = "Content";

并且假设您已正确地将.spriteFont文件添加到您的内容项目并且它正在正确构建.检查是否在可执行文件旁边的Content目录中创建了Arial.xnb文件(在bin / DeBUG或bin / Release中,具体取决于您的构建目标).

如果您仍有问题,请尝试创建一个新的XNA项目,看看是否可以使用该字体.

总结

以上是内存溢出为你收集整理的c# – 无法在XNA4中加载spriteFont全部内容,希望文章能够帮你解决c# – 无法在XNA4中加载spriteFont所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1262999.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-08
下一篇2022-06-08

发表评论

登录后才能评论

评论列表(0条)

    保存