WPF Can't Find some Fonts

2019-08-30 09:29发布

问题:

Why is it that Media.Fonts can't find "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";
    }
}

回答1:

Check in your system's Windows folder. Do u have "Arial Rounded MT Bold" font installed on your system?? You might not have the font installed on your system.. That might be the only issue for not finding it..

Ok, i got it in first loop you are looping through System Font families and for "Arial Rounded MT Bold" its font family is "Arial Rounded MT". You can check about its specification here - http://www.microsoft.com/typography/fonts/font.aspx?FMID=918

So, if you update your code like this -

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

You will get that font which you are looking for..



标签: wpf fonts