关闭

枚举系统字体

1256人阅读 评论(0) 收藏 举报

在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);

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:18668次
    • 积分:366
    • 等级:
    • 排名:千里之外
    • 原创:13篇
    • 转载:2篇
    • 译文:0篇
    • 评论:25条
    文章分类
    最新评论