在C#中枚举字体
2010-03-31 21:10
507 查看
在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);
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);
相关文章推荐
- C# 枚举与switch用法
- C#的枚举Enum注意的问题
- C# 让枚举返回字符串
- C# 如何把字符串转换为枚举
- C#枚举(Enums)
- C#中怎么压扁字体
- C#枚举和结构体
- [转]嵌入字体到程序 Winform C#
- 在C#中获得系统字体的名称,并将他们添加到Combobox中
- C#枚举中使用Flags特性
- C# 遍历枚举
- C# 枚举、字符串、值的相互转换
- C#枚举遍历--Enum
- C# 枚举类型
- [c#]遍历枚举中的项目名称和数值
- 浅谈C#中的枚举
- 浅谈C#中的枚举
- c#中的枚举(enum)
- C#零基础入门04:打老鼠初级之枚举、重构、事件处理器
- C# 异常类 Exception 枚举所有类型的异常