2011-04-16 29 views
0

Media.Fonts爲什麼找不到"Arial Rounded MT Bold"WPF找不到字幕

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

檢入您的系統的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"; 
     } 
} 

你會得到字體,你正在尋找..

+0

是的,我確實有它安裝。我不僅可以瀏覽它,而且代碼示例中的第二個foreach循環將查找字體。 – dnndeveloper 2011-04-16 22:03:34

+0

我已經更新了我的答案。希望這是你所要求的,如果我找到你的權利。 – 2011-04-17 09:55:49

+0

總結 - 您的答案是否是SystemFontFamilies與Arial Rounded MT的InstalledFontCollection名稱不同? InstalledFontCollection將「BOLD」追加到最後?這是我懷疑的並且很難將winform(System.Drawing)字體轉換爲WPF(System.Windows.Media)字體。 – dnndeveloper 2011-04-17 10:47:44