H
hoppy
I was banging my head against the wall with this code in a sub:
Dim writing As New Bitmap(ctrl.Width, ctrl.Height)
Dim surface As Graphics = Graphics.FromImage(writing)
surface.DrawString(textToWrite, font1, Brushes.Black, 0, 0)
ctrl.Image = writing
It produced terribly blocky text.
I finally added:
surface.TextRenderingHint =
System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit
Which cleared up the mess.
I then got thinking - both machines I was testing it on have lcd's and
cleartype enabled in the control panel. I went and switched it off, and
tried the basic code again and it worked without producing the weird text.
See piccy:
http://www.psatracker.co.uk/pics/Cleartype.gif
If you create a graphics object in a controls paint event and use the same
code to draw a string on that then you don't get the blocky text.
Weird. Anyone know how to detect if the user has Cleartype switched on? I'm
using the cleartpye tuning wizard in the control panel to enable cleartype
if it is relevant.
Dim writing As New Bitmap(ctrl.Width, ctrl.Height)
Dim surface As Graphics = Graphics.FromImage(writing)
surface.DrawString(textToWrite, font1, Brushes.Black, 0, 0)
ctrl.Image = writing
It produced terribly blocky text.
I finally added:
surface.TextRenderingHint =
System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit
Which cleared up the mess.
I then got thinking - both machines I was testing it on have lcd's and
cleartype enabled in the control panel. I went and switched it off, and
tried the basic code again and it worked without producing the weird text.
See piccy:
http://www.psatracker.co.uk/pics/Cleartype.gif
If you create a graphics object in a controls paint event and use the same
code to draw a string on that then you don't get the blocky text.
Weird. Anyone know how to detect if the user has Cleartype switched on? I'm
using the cleartpye tuning wizard in the control panel to enable cleartype
if it is relevant.