0

我刚刚为 Windows Phone 安装了 Windows 8 和 Visual Studio Express 2012 ......但我不再能够编译包含 Segoe WP 类型的 spritefonts 的 XNA 项目(相同的项目确实可以使用 Visual Studio Express 2010 成功编译Windows 电话):

<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>Segoe WP</FontName>

    <!--
    Size is a float value, measured in points. Modify this value to change
    the size of the font.
    -->
    <Size>14</Size>

    ...
</XnaContent>

上面的代码片段总是会产生以下构建错误:

Error 1 Building content threw NotSupportedException: Specified method is not supported. at Microsoft.Xna.Framework.Content.Pipeline.Interop.KerningHelper.GetCharacterSpacing(Char c) at Microsoft.Xna.Framework.Content.Pipeline.Processors.FontDescriptionProcessor.Process(FontDescription input, ContentProcessorContext context) at Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor'2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context) at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item) at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item) at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild() at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary'2& dependencyTimestamps, KeyValuePair'2[]& warnings)

如果我替换<FontName>Segoe WP</FontName><FontName>Segoe UI Mono</FontName>,则编译成功。

有没有人经历过类似的事情?有解决方法/修复吗?任何帮助将非常感激。

4

1 回答 1

0

此错误来自内容处理器内部。GetCharacterSpacing出于某种原因,用于确定字符宽度的内部方法不支持该字体。

(疯狂猜测原因:也许 2012 年的构建过程正在使用较新版本的 .NET 框架 - 例如:4.5 vs 4.0 - 由于某些疯狂的原因,该特定方法在版本之间的工作方式不同。你可能与 MSBuild 混为一谈 - 但这太费力了。)

如果它在 2010 年有效,您可以直接使用xnb在该 IDE 中完成的构建生成的文件。

更好的选择可能是使用Nuclex.Fonts这使用 FreeType 来呈现字体 - 所以它根本不需要 Windows API。它还提供比 XNA 的内置处理器更好的结果(主要是因为它不会有损压缩其输出)。它是一个插入式替代品——它读取相同的 XML 文件并输出相同的SpriteFont对象。

于 2013-06-09T08:16:41.047 回答