linux - 运行时Monogame "Could not find font file"

标签 linux visual-studio-code fonts monogame

我正在尝试学习 Monogame 的基础知识,并且我已经成功地弄清楚了如何使用 Monogame 内容管道在屏幕上加载和显示图像。当我尝试对字体执行相同操作时,通过将名为 galleryFont.spritefont 的字体加载到 Monogame 内容管道中,一切都很好。

请注意:甚至在将字体导入代码之前,我都会收到错误。

enter image description here

但是,当我运行项目时,出现了问题。我收到如下错误:

enter image description here

它指出:

error : Processor 'FontDescriptionProcessor' had unexpected failure! System.IO.FileNotFoundException: Could not find "Arial" font file

我的构建任务中也出现错误,说明如下:

enter image description here

正如您所看到的,文件已加载,但我注意到奇怪的是单游戏内容管道没有将文件保存为 中的 .xnb 文件Content/bin 文件夹。

enter image description here

或者由于错误显示“无法找到 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>&#32;</Start>
        <End>&#126;</End>
      </CharacterRegion>
    </CharacterRegions>
  </Asset>
</XnaContent>

感谢您的帮助。

最佳答案

经过大量研究后,我发现该字体并未自然加载到我的计算机上。我使用的教程不知何故已经加载了 Arial 字体,所以他们可以只使用 <FontName>Arial</FontName>加载字体。但是,我必须下载一种字体,将其放入我的 Content 中目录,然后编辑 .spritefont文件至<FontName>font.ttf</FontName> 。最后,完成此操作后,项目就可以运行了。

关于linux - 运行时Monogame "Could not find font file",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73583464/

相关文章:

php - VScode PHPCS 扩展错误 : Referenced Sniff "WordPress-Core" does not exist

C# webbrowser 控件 - 我想使用/链接特定字体

html - 使用@fontface 更改 Jquery UI 字体

javascript - GNU+Linux 中的 Electron 无法最大化子窗口

linux - 将两列数据格式化为三列数据

c++ - 为什么我不能使用 EGL 创建 headless OpenGl 上下文?

git - 我的 .git 文件安全吗?太多的事件更改问题

c++ - 错误:<位/stdc++。h>,未找到 'cstdalign'文件,正在运行C++ 17

javascript - 仅使用 javascript 更改选择选项的顺序

c - 如何分配ION的预定义堆类型的内存?