1 Replies - 2035 Views - Last Post: 15 January 2012 - 11:10 PM Rate Topic: -----

#1 Alyssa Saila  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 07-January 12

AntiAliasing Text In Windows Form? (All Text Appears Jagged)

Posted 15 January 2012 - 10:56 PM

Using VB Windows Form Application In Visual Studio,

All of my text appears jagged and pixelated.

I calibrated my PC clear type settings (all fonts are smooth).

However, in the Form Designer of VS, the text on buttons, labels, etc are not.

I've tried the working code below (please try the code)
Imports System.Drawing.Text
Public Class Form1
     Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim myChosenFont As New Font("Times New Roman", 75, FontStyle.Bold, GraphicsUnit.Pixel)

		e.Graphics.DrawString("Antialiasing Off", myChosenFont, Brushes.Black, 10, 10)

        e.Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit

        e.Graphics.DrawString("Antialiasing On", myChosenFont, Brushes.Black, 10, 80)

	End Sub
End Class


Although it works, for reasons unknown to me:
-It does not smooth out any pre-existing text created by the form designer.
-It does not work on my buttons, labels, textboxes, etc..
-It only draws new text programatically to the form itself only.


Determined but unsuccesful, I tried the links below and attempted these to no avail:
http://www.java2s.co...liasGridFit.htm
http://msdn.microsof...y/a619zh6z.aspx
http://www.vb-helper...alias_text.html (where I received the code above from)

Is there a way to antialias smooth text throughout my entire project?

If so, could someone please provide a working example for me to use?


Is This A Good Question/Topic? 0
  • +

Replies To: AntiAliasing Text In Windows Form? (All Text Appears Jagged)

#2 DimitriV  Icon User is offline

  • Don't try to save yourself… the circle is complete
  • member icon

Reputation: 544
  • View blog
  • Posts: 2,632
  • Joined: 24-July 11

Re: AntiAliasing Text In Windows Form? (All Text Appears Jagged)

Posted 15 January 2012 - 11:10 PM

Quote

-It only draws new text programatically to the form itself only.

It might be because the code you have is inside the Form's paint event. This means that only the form - none of its child controls - just the form, is having text printed to it. You're calling DrawString on the graphics paint event of the form. If you wanted to, after Handles Form1.Paint, you could put the names of the rest of your controls separated by a comma, and this sub will now handle all of their paint events.

Ps: thanks for posting a thread. In future, don't PM me.
Pps: dumb question, but did you click the VB tab in the code example? http://msdn.microsof...9zh6z.aspx#Y464
Ppps: this link - http://www.java2s.co...liasGridFit.htm - was under the WPF section of the site.

This post has been edited by jimmyBo: 15 January 2012 - 11:15 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1