Draw Font Families Formatted : Font : Drawing 2D C# Examples


C# Examples » Drawing 2D » Font »

 

Draw Font Families Formatted








    
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());
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Drawing 2D
» Font