using System;
using System.Drawing;
using System.Windows.Forms;
public class DrawFontFamiliesFormatted : Form
{
public DrawFontFamiliesFormatted()
{
ResizeRedraw = true;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
float y= 10;
Font fnt;
Graphics g = e.Graphics;
StringFormat fmt = new StringFormat();
fmt.Alignment = StringAlignment.Center;
FontFamily[] ffArray = FontFamily.Families;
foreach( FontFamily ff in ffArray )
{
if (ff.IsStyleAvailable(FontStyle.Regular))
{
fnt = new Font(ff, 10);
Brush b = new SolidBrush(ForeColor);
g.DrawString(ff.Name, fnt, b, ClientSize.Width / 2, (int)y, fmt);
y += fnt.GetHeight();
}
}
}
static void Main()
{
Application.Run(new DrawFontFamiliesFormatted());
}
}
|