Graphics.TextRenderingHint
/*
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 Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#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(272, 168);
this.Label3.Name = "Label3";
this.Label3.Size = new System.Drawing.Size(128, 16);
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(272, 100);
this.Label2.Name = "Label2";
this.Label2.Size = new System.Drawing.Size(128, 16);
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(272, 36);
this.Label1.Name = "Label1";
this.Label1.Size = new System.Drawing.Size(128, 16);
this.Label1.TabIndex = 3;
this.Label1.Text = " SingleBitPerPixelGridFit";
//
// SmoothingFonts
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.ClientSize = new System.Drawing.Size(440, 314);
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, 20, 20);
e.Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
e.Graphics.DrawString("Sample Text", TextFont, Brushes.Black, 20, 85);
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
e.Graphics.DrawString("Sample Text", TextFont, Brushes.Black, 20, 150);
}
}
}
Related examples in the same category
| 1. | Graphics.Clear | | |
| 2. | Graphics.CopyFromScreen | | |
| 3. | Graphics.DashCap | | |
| 4. | Graphics.Dispose() | | |
| 5. | Graphics.DpiX | | |
| 6. | Graphics.DpiY | | |
| 7. | Graphics.DrawArc | | |
| 8. | Graphics.DrawBeziers | | |
| 9. | Graphics.DrawEllipse | | |
| 10. | Graphics.DrawIcon(Icon icon, int x, int y) | | |
| 11. | Graphics.DrawImage(Image i, int x, int y); | | |
| 12. | Graphics.DrawImage(Image img, int x, int y, int width, int height) | | |
| 13. | Graphics.DrawImage(im, rec, recPart, GraphicsUnit.Pixel) | | |
| 14. | Graphics.DrawImage(Image, Points[]) | | |
| 15. | Graphics.DrawLine(Pen p, int x0,int y0, int x1, int y1) | | |
| 16. | Graphics.DrawLine(Pen,Point point1, Point point2) | | |
| 17. | Graphics.DrawLines(Pen pen, Point[] points) | | |
| 18. | Graphics.DrawPie | | |
| 19. | Graphics.DrawRectangle | | |
| 20. | Graphics.DrawRectangles | | |
| 21. | Graphics.DrawString | | |
| 22. | Graphics.EnumerateMetafileProc | | |
| 23. | Graphics.FillClosedCurve | | |
| 24. | Graphics.FillEllipse | | |
| 25. | Graphics.FillEllipse(Brush brush,int x, int y,int width,int height) | | |
| 26. | Graphics.FillPath(Brushes.AliceBlue, myPath); | | |
| 27. | Graphics.FillPolygon | | |
| 28. | Graphics.FillRectangle | | |
| 29. | Graphics.FillRectangles | | |
| 30. | Graphics.FillRegion | | |
| 31. | Graphics.FromHwnd() | | |
| 32. | Graphics.FromImage | | |
| 33. | Graphics.InterpolationMode | | |
| 34. | Graphics.MeasureString | | |
| 35. | Graphics.PageScale | | |
| 36. | Graphics.PageUnit | | |
| 37. | Graphics.PixelOffsetMode | | |
| 38. | Graphics.ReleaseHdc | | |
| 39. | Graphics.RotateTransform | | |
| 40. | Graphics.ScaleTransform | | |
| 41. | Graphics.SetClip | | |
| 42. | Graphics.SetClip(path, (CombineMode)miCombineMode.Index) | | |
| 43. | Graphics.SmoothingMode | | |
| 44. | Graphics.Transform | | |
| 45. | Graphics.TranslateClip | | |
| 46. | Graphics.TranslateTransform | | |
| 47. | Graphics.VisibleClipBounds | | |