A .NET Technology blog | .NET,C# Progamming,C# tutorials,WPF WCF|Software Engineer


What Is SetCompatibleTextRenderingDefault (false)

Application.SetCompatibleTextRenderingDefault Method

SetCompatibleTextRenderingDefault (false) is an automatic method generated in the Main method of Program.cs file. Since it is automatically generated we normally don’t give any attention to this method.
static class Program
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    static void Main()
        Application.Run(new Form1());
This article is to just to give you a brief idea about SetCompatibleTextRenderingDefault  and what happens if we pass true instead of false.
In .NET Framework versions 1.0 and 1.1 applications Windows Forms controls render their text using Grpahics  class which is based on GDI+ graphics. GDI+ based graphics was having some performance and localization issues.
From .NET Framework version 2.0 onwards TextRenderer class got introduced which is based on GDI graphics library to overcome the performance and localization issues of GDI+ based text rendering. Also the text looks better in GDI based rendering and has improved support for international fonts.
Calculation of character spacing, word wrapping etc. are different in GDI based rendering and GDI+ based rendering.
By default, UseCompatibleTextRendering property takes the value false. But In a Windows Forms application which uses the Graphics class to render text and having certain controls that use TextRenderer class to render text to appear different from the other text in the application, then to overcome this incompatibility issue we can set the UseCompatibleTextRendering property to true. Otherwise you don’t need to change the method call at all.

Comments (1) -

Jerrell Wendlandt
United States Jerrell Wendlandt

I’m impressed, I must say. Seldom do I come across a blog that’s both educative and interesting, and without a doubt, you have hit the nail on the head. The issue is something too few men and women are speaking intelligently about. Now i'm very happy I found this in my search for something regarding this.


Pingbacks and trackbacks (1)+

Add comment

  Country flag

  • Comment
  • Preview