Font with different size : Font « GUI Windows Form « C# / C Sharp






Font with different size

 


using System;
using System.Drawing;
using System.Windows.Forms;
   
class TwentyFourPointPrinterFonts: Form
{
     public static void Main()
     {
          Application.Run(new TwentyFourPointPrinterFonts());
     }
     public TwentyFourPointPrinterFonts()
     {
          Text = "Twenty-Four Point Printer Fonts";
          ResizeRedraw = true; 
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
     }     
     protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
     {
          Brush  brush     = new SolidBrush(clr);
          float  y         = 0;
          Font   font;
          string strFamily = "Times New Roman";
   
          font = new Font(strFamily, 24);
          grfx.DrawString("No GraphicsUnit, 24 points", font, brush, 0, y);
          y += font.GetHeight(grfx);
   
          font = new Font(strFamily, 24, GraphicsUnit.Point);
          grfx.DrawString("GraphicsUnit.Point, 24 units", font, brush, 0, y);
          y += font.GetHeight(grfx);
   
          font = new Font(strFamily, 1/ 3f, GraphicsUnit.Inch);
          grfx.DrawString("GraphicsUnit.Inch, 1/3 units", font, brush, 0, y);
          y += font.GetHeight(grfx);
   
          font = new Font(strFamily, 25.4f / 3, GraphicsUnit.Millimeter);
          grfx.DrawString("GraphicsUnit.Millimeter, 25.4/3 units", 
                          font, brush, 0, y);
          y += font.GetHeight(grfx);
   
          font = new Font(strFamily, 100, GraphicsUnit.Document);
          grfx.DrawString("GraphicsUnit.Document, 100 units", 
                          font, brush, 0, y);
          y += font.GetHeight(grfx);
   
          font = new Font(strFamily, 100f / 3, GraphicsUnit.Pixel);
          grfx.DrawString("GraphicsUnit.Pixel, " + 100f / 3 + " units",
                          font, brush, 0, y);
          y += font.GetHeight(grfx);
   
          font = new Font(strFamily, 100f / 3, GraphicsUnit.World);
          grfx.DrawString("GraphicsUnit.World, " + 100f / 3 + " units", 
                          font, brush, 0, y);
     }
}

 








Related examples in the same category

1.All font properties
2.new Font("Times New Roman", 10, FontStyle.Italic)
3.new Font(strFont, fSize)
4.new Font(fontRegular, FontStyle.Italic);
5.Text on Baseline
6.Font: SizeInPoints
7.Font: GetHeight
8.System Fonts: Icon Title FontSystem Fonts: Icon Title Font
9.Load all system installed fontsLoad all system installed fonts
10.Timer based animation for fontTimer based animation for font
11.Get all system installed fontGet all system installed font
12.Font listFont list