【问题标题】:WPF Can't Find some FontsWPF 找不到某些字体
【发布时间】:2011-08-06 17:40:05
【问题描述】:

为什么Media.Fonts找不到"Arial Rounded MT Bold"

foreach (var f in System.Windows.Media.Fonts.SystemFontFamilies)
{
    if (f.Source == "Arial Rounded MT Bold")
    {
        var x = "Not Found";
    }
}

var fc = new System.Drawing.Text.InstalledFontCollection();
foreach (var fd in fc.Families)
{
    if (fd.Name == "Arial Rounded MT Bold")
    {
        var x = "Found";
    }
}

【问题讨论】:

    标签: wpf fonts


    【解决方案1】:

    检查系统的 Windows 文件夹。你的系统上安装了“Arial Rounded MT Bold”字体吗?您的系统上可能没有安装该字体。这可能是找不到它的唯一问题。

    好的,我在第一个循环中得到它,您正在循环系统字体系列,对于“Arial Rounded MT Bold”,它的字体系列是“Arial Rounded MT”。您可以在此处查看其规格 - http://www.microsoft.com/typography/fonts/font.aspx?FMID=918

    所以,如果你像这样更新你的代码 -

    foreach (var f in System.Windows.Media.Fonts.SystemFontFamilies)
    {
          if (f.Source == "Arial Rounded MT")
          {
             var x = "Found";
          }
    }
    

    你会得到你正在寻找的字体..

    【讨论】:

    • 是的,我确实安装了它。我不仅可以浏览到它,而且代码示例中的第二个 foreach 循环也会找到字体。
    • 我已经更新了我的答案。如果我说对了,希望这就是您所要求的。
    • 总而言之-您的答案是 SystemFontFamilies 的名称与 Arial Rounded MT 的 InstalledFontCollection 名称不同吗? InstalledFontCollection 将“BOLD”附加到末尾?这是我所怀疑的,并且很难将 winform (System.Drawing) 字体转换为 WPF(System.Windows.Media) 字体。
    • 是的 SystemFontFamilies 仅包含家族名称,例如如果您签入这两个集合 - SystemFontFamilies 将只有一个“Arial”字体家族的值,而在 InstalledFontCollection 中将具有三个不同的值,即 - “Arial”、“ Arial Narrow”、“Arial Black”。 SystemFontFamilies 仅包含准确的字体系列。
    猜你喜欢
    • 2016-08-06
    • 2011-08-21
    • 1970-01-01
    • 1970-01-01
    • 2020-03-19
    • 1970-01-01
    • 2021-02-02
    • 1970-01-01
    • 2021-10-27
    相关资源
    最近更新 更多