【发布时间】:2022-09-26 05:59:53
【问题描述】:
我正在尝试学习 Monogame 的基础知识,并且我已经成功地弄清楚了如何使用 Monogame Content Pipeline 在屏幕上加载和显示图像。当我尝试对字体做同样的事情时,通过将名为 galleryFont.spritefont 的字体加载到 Monogame 内容管道中,一切都很好。
请注意:甚至在我将字体导入我的代码之前,我都会收到错误消息。
但是,当我运行项目时会出现问题。我收到如下所示的错误:
它指出:
错误:处理器“FontDescriptionProcessor”出现意外故障! System.IO.FileNotFoundException: 找不到 \"Arial\" 字体文件
我的构建任务也出现错误,说明如下:
正如您所看到的,文件已加载,但我注意到奇怪的是,monogame 内容管道没有将文件保存为
.xnb文件夹中的.xnb文件。或者由于错误说“找不到 Arial 字体文件”,这是否意味着我需要以某种方式下载 Arial font.ttf 并以某种方式将其链接到我的
.spritefont文件中?如果有人感兴趣,这里是.spritefont文件。<?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>Arial</FontName> <Size>24</Size> <Spacing>0</Spacing> <UseKerning>true</UseKerning> <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> <CharacterRegion> <Start> </Start> <End>~</End> </CharacterRegion> </CharacterRegions> </Asset> </XnaContent>谢谢你的帮助。
-
向我们展示您正在使用加载字体的代码。这就是问题所在。
-
@Frecklefoot 我收到错误甚至在我在代码中加载字体之前。我相信问题出在 mgcb-editor 上,因为 font.xml 没有出现。我还添加了在构建项目时发现的另一个错误。
标签: linux visual-studio-code fonts monogame