技术改变世界!学习改变自己!

每天进步一点点,遥不可及的事情,在你一点一滴的努力下,也会变成现实。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

在C#中每一种字体都用FontFamily类来表示,如下:
FontFamily fontFamily = new FontFamily("Arial");
Font font = new Font(
   fontFamily,
   8,
   FontStyle.Regular,
   GraphicsUnit.Point);
RectangleF rectF = new RectangleF(10, 10, 500, 500);
SolidBrush solidBrush = new SolidBrush(Color.Black);

string familyName;
string familyList = "";
FontFamily[] fontFamilies;  //定义一个装载字体信息的字体类数组
//通过InstalledFontCollection类的Families属性来获取系统安装的所有字体
InstalledFontCollection installedFontCollection = new InstalledFontCollection();
// Get the array of FontFamily objects.
fontFamilies = installedFontCollection.Families;
//循环打印字体信息
int count = fontFamilies.Length;
for(int j = 0; j < count; ++j)
{
   familyName = fontFamilies[j].Name; 
   familyList = familyList + familyName;
   familyList = familyList + ",  ";
}
// Draw the large string (list of all families) in a rectangle.
e.Graphics.DrawString(familyList, font, solidBrush, rectF);

posted on 2010-03-31 21:10  阿捷  阅读(4172)  评论(0编辑  收藏  举报