Visual Studio 2012 for Windows Phone:字体Segoe WP无法编译



我刚刚为Windows Phone安装了Windows 8和Visual Studio Express 2012…但是我不再能够编译包含Segoe WP类型spritefts的XNA项目(相同的项目使用Windows Phone的Visual Studio Express 2010成功编译):

<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>,则编译成功。

有人经历过类似的事情吗?有解决办法吗?

这个错误来自于内容处理器内部。由于某种原因,该字体不被用于计算字符宽度的内部GetCharacterSpacing方法所支持。

(疯狂地猜测一下原因:也许2012年的构建过程使用了一个新版本的。net框架——例如:4.5 vs 4.0——由于一些疯狂的原因,那个特定的方法在不同版本之间的工作方式不一样。你也许可以在MSBuild上搞砸-但那太费力气了。

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

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

最新更新