c# - SpriteFont 不适用于 MonoGame

标签 c# xna xna-4.0 monogame spritefont

font = Content.Load<SpriteFont>("TopBarFont");

无论出于何种原因,无论发生什么,或者我做了什么更改,我总是会收到此错误。

An unhandled exception of type 'System.NotImplementedException' occurred in MonoGame.Framework.dll Additional information: The method or operation is not implemented.

我将内容文件夹中的 TopBarFont.spritefont 设置为内容,并始终像我所有其他 Assets 一样复制到输出目录。

我的 spritefont 文件看起来像这样,

<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
    <Asset Type="Graphics:FontDescription">
        <FontName>Open Sans Light</FontName>
        <Size>36</Size>
        <Spacing>0</Spacing>
        <UseKerning>true</UseKerning>
        <Style>Regular</Style>
        <CharacterRegions>
            <CharacterRegion>
                <Start>&#32;</Start>
                <End>&#126;</End>
            </CharacterRegion>
        </CharacterRegions>
    </Asset>
</XnaContent>

我看到其他一些帖子只使用 2d 纹理并绘制它,但没有..这默认了使用 DrawString 的全部目的。

最佳答案

使用this将 .SpriteFont 转换为 .xnb 的转换器

关于c# - SpriteFont 不适用于 MonoGame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31330724/

相关文章:

xna - 来自少数 Draw() 调用的 Monogame XNA 低帧率

c# - 在 XNA 中动态滚动 List<Rectangle>

c# - 服务引用 - 为什么在引用的程序集中重用类型

c# - 我是否以正确的方式使用静态?

c# - 获取类c#的路径

c# - 如何从Texture2D XNA c#获取颜色和坐标(x,y)?

c# - XNA GS 安装程序无法识别 c#?

c# - 为什么 VertexBuffer 比 DynamicVertexBuffer 更快

C# 将对象添加到 listBox,然后更改它们的参数

c# - 使用Linq-to-Nhibernate从50多个表中获取数据