ASP.NET MVC 获取计算机字体

       //加载计算机上可用的字体
        public string LoadFonts()
        {
            try
            {
                var fontCollection = new InstalledFontCollection();
                var mycomputerfonts = fontCollection.Families;
                if (!mycomputerfonts.Any()) return null;
                var list = new List<string>(0);
                var newfonts = mycomputerfonts.Reverse().ToList();
                list.AddRange(newfonts.Select(fontFamily => fontFamily.Name));
                return JsonConvert.SerializeObject(list);
            }
            catch (Exception ex)
            {
                return null;
            }
        }

 

posted @ 2015-01-14 10:18  b̶i̶n̶g̶.̶  阅读(317)  评论(0编辑  收藏  举报