Search code examples
visual-studiofontswindows-xpgdi+smoothing

Visual Studio & GDI++


I tried to find a similar question here, but found something different. I prefer to use display fonts smoothing in Windows, but I don't like the way how Windows XP smoothes the display font edges. Currently I use GDI++ that smoothes the display fonts making them look very similar to text rendered in Safari browser for Windows (as far as I know, not a Mac user, it's a native approach to MacOS). Great, GDI++ really renders the fonts very similar to Safari almost for all application I use, but I'm disappointed knowing that GDI++ does not (and can't?) support Visual Studio and Google Chrome. I guess these applications use somewhat another way to render the display fonts (just GDI O_o; and I guess they take into consideration Windows font edges smoothing settings [no smoothing, Standard or ClearType]), but I'm not sure and I'm not familiar with it. :(

Please clarify this to me. I'd really like to use GDI++ in Visual Studio and Google Chrome. Probably, someone uses some workarounds (sure, if it's possible). Thank you.


Solution

  • This blog post by our esteemed benefactor is relevant. GDI+ indeed does things the Apple way, it uses true resolution independent rendering. It was pretty widely panned for this, so much so that it was replaced in .NET 2.0 with the TextRenderer class. Which uses the GDI DrawTextEx() function to draw text. To give an example of how GDI+ can suck, try running this sample Windows Forms form:

      public partial class Form1 : Form {
        public Form1() {
          InitializeComponent();
        }
        protected override void OnPaint(PaintEventArgs e) {
          e.Graphics.DrawString("Hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii!", this.Font, Brushes.Black, 0, 0);
        }
      }
    

    YMMV, but I haven't yet had a machine where that didn't look completely awful. TextRenderer saved the day.

    Until .NET 3.0 when WPF was introduced. Back to resolution independent rendering. The amount of hate that generated was stunning.

    Long story short, the majority of users like GDI text rendering. Or at least they get very vocal when they don't get it. Visual Studio and Chrome no doubt use GDI for text output. This is not something you can easily change yourself, although Chrome is open source afaik.

    Just wait for the next version. Visual Studio 2010 will use WPF. Beta 1 generated a lot of hate for blurry text. But WPF has been tweaked to limit the fuzzies so it might not fit your taste anymore.