首页 > Windows开发 > 详细

wpf获取系统字体

时间:2015-03-24 22:56:57      阅读:711      评论:0      收藏:0      [点我收藏+]

wpf获取系统安装的字体很简单,

foreach (FontFamily fontfamily in Fonts.SystemFontFamilies)

{

  //代码

}

获取中文字体

foreach (FontFamily fontfamily in Fonts.SystemFontFamilies)
            {
                LanguageSpecificStringDictionary fontdics = fontfamily.FamilyNames;
                //判断该字体是不是中文字体
                if (fontdics.ContainsKey(XmlLanguage.GetLanguage("zh-cn")))
                {
                    string fontfamilyname = null;
                    if (fontdics.TryGetValue(XmlLanguage.GetLanguage("zh-cn"), out fontfamilyname))
                    {
                        systemFontsNamesList.Add(fontfamilyname);
                    }
                }

     //英文字体
                else
                {
                    string fontfamilyname = null;
                    if (fontdics.TryGetValue(XmlLanguage.GetLanguage("en-us"), out fontfamilyname))
                    {
                        systemFontsNamesList.Add(fontfamilyname);
                    }
                }
            }

wpf获取系统字体

原文:http://www.cnblogs.com/renpeng/p/4364194.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!