【发布时间】:2019-12-29 15:36:30
【问题描述】:
我们正在将 WPF 应用程序从 .NET Framework 迁移到 .NET Core 3.1。
在处理此问题时,我必须将 xaml 中的所有引用从 xmlns:system="clr-namespace:System;assembly=mscorlib" 交换为 xmlns:system="clr-namespace:System;assembly=System.Runtime"。非常有意义,mscorlib 用于 .NET Framework,System.Runtime 用于 .NET Core。阅读更多here。
启动应用程序时,我发现没有加载复合字体的问题。因为我只是将mscorlib 替换为System.Runtime,所以文件看起来像这样:
<FontFamily xmlns="http://schemas.microsoft.com/winfx/2006/xaml/composite-font"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=System.Runtime">
<!-- Name mapping -->
<FontFamily.FamilyNames>
<system:String x:Key="en-US">My Font</system:String>
</FontFamily.FamilyNames>
<FontFamily.FamilyMaps>
...
</FontFamily.FamilyMaps>
</FontFamily>
但我还是有问题。所以我将这个文件改回使用 mscorlib,如下所示:
<FontFamily xmlns="http://schemas.microsoft.com/winfx/2006/xaml/composite-font"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<!-- Name mapping -->
<FontFamily.FamilyNames>
<system:String x:Key="en-US">Cabo Font</system:String>
</FontFamily.FamilyNames>
<FontFamily.FamilyMaps>
...
</FontFamily.FamilyMaps>
</FontFamily>
现在一切都很完美。
有人能很好地解释为什么会这样吗?
【问题讨论】:
-
编码有问题或字体相关问题您能解释一下,您遇到了什么问题吗?
-
问题是没有加载复合字体。有一些 unicode 映射到不同的字体。但主要问题是它没有加载。
-
您的应用中是否默认启用了
en-US文化? -
我认为您误解了这个问题。现在一切正常。我想知道它为什么有效。为什么引用
System.Runtime不起作用,但使用mscorlib起作用。
标签: wpf .net-core fonts .net-4.0