我怎样才能转换System.Drawing.Font
to a System.Windows.Media.Fonts
or TypeFace
?
或者我如何生成一个实例System.Windows.Media.Fonts
or TypeFace
从一个实例System.Drawing.Font
?
你无法实例化媒体.字体,但我认为你可以获得媒体.字体家族这就是我实现它的方法。
using System.Drawing;
using Media = System.Windows.Media;
Font font = new Font(new System.Drawing.FontFamily("Comic Sans MS"), 10);
//option 1
Media.FontFamily mfont = new Media.FontFamily(font.Name);
//option 2 does the same thing
Media.FontFamilyConverter conv = new Media.FontFamilyConverter();
Media.FontFamily mfont1 = conv.ConvertFromString(font.Name) as Media.FontFamily;
//option 3
Media.FontFamily mfont2 = Media.Fonts.SystemFontFamilies.Where(x => x.Source == font.Name).FirstOrDefault();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)