Smoothing Fonts : Font « 2D Graphics « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » 2D Graphics » FontScreenshots 
Smoothing Fonts
Smoothing Fonts

/*
User Interfaces in C#: Windows Forms and Custom Controls
by Matthew MacDonald

Publisher: Apress
ISBN: 1590590457
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Text;

namespace GDI_Basics
{
    /// <summary>
    /// Summary description for SmoothingFonts.
    /// </summary>
    public class SmoothingFonts : System.Windows.Forms.Form
    {
        internal System.Windows.Forms.Label Label3;
        internal System.Windows.Forms.Label Label2;
        internal System.Windows.Forms.Label Label1;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public SmoothingFonts()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Disposebool disposing )
        {
            ifdisposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Disposedisposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.Label3 = new System.Windows.Forms.Label();
            this.Label2 = new System.Windows.Forms.Label();
            this.Label1 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // Label3
            // 
            this.Label3.BackColor = System.Drawing.Color.White;
            this.Label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.Label3.Location = new System.Drawing.Point(272168);
            this.Label3.Name = "Label3";
            this.Label3.Size = new System.Drawing.Size(12816);
            this.Label3.TabIndex = 5;
            this.Label3.Text = " ClearTypeGridFit";
            // 
            // Label2
            // 
            this.Label2.BackColor = System.Drawing.Color.White;
            this.Label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.Label2.Location = new System.Drawing.Point(272100);
            this.Label2.Name = "Label2";
            this.Label2.Size = new System.Drawing.Size(12816);
            this.Label2.TabIndex = 4;
            this.Label2.Text = " AntiAliasGridFit";
            // 
            // Label1
            // 
            this.Label1.BackColor = System.Drawing.Color.White;
            this.Label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.Label1.Location = new System.Drawing.Point(27236);
            this.Label1.Name = "Label1";
            this.Label1.Size = new System.Drawing.Size(12816);
            this.Label1.TabIndex = 3;
            this.Label1.Text = " SingleBitPerPixelGridFit";
            // 
            // SmoothingFonts
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(514);
            this.ClientSize = new System.Drawing.Size(440314);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.Label3,
                                                                          this.Label2,
                                                                          this.Label1});
            this.Font = new System.Drawing.Font("Tahoma"8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.Name = "SmoothingFonts";
            this.Text = "SmoothingFonts";
            this.Paint += new System.Windows.Forms.PaintEventHandler(this.SmoothingFonts_Paint);
            this.ResumeLayout(false);

        }
        #endregion


        [STAThread]
        static void Main() 
        {
            Application.Run(new SmoothingFonts());
        }

        private void SmoothingFonts_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            Font TextFont = new Font("Times New Roman"25, FontStyle.Italic);
            e.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            e.Graphics.DrawString("Sample Text", TextFont, Brushes.Black, 2020);
            e.Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
            e.Graphics.DrawString("Sample Text", TextFont, Brushes.Black, 2085);
            e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            e.Graphics.DrawString("Sample Text", TextFont, Brushes.Black, 20150);
        }
    }
}



           
       
Related examples in the same category
1.Draw font cell ascent, cell descent, line space, em height
2.Get font family infoGet font family info
3.Get font from Font dialog and redraw stringGet font from Font dialog and redraw string
4.Font size, name and strike outFont size, name and strike out
5.Font AttributesFont Attributes
6.Fonts ClassFonts Class
7.Font Metrics
8.Font ViewerFont Viewer
9.Font FamyliesFont Famylies
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.