Home All Groups Group Topic Archive Search About

The string font is ugly on chart

Author
27 Apr 2010 10:54 AM
yxq
I found a good article about the disk explorer
http://www.codeproject.com/KB/vb/Disk_Size_Explorer.aspx

And it ran well on Windows XP, but the text font on the chart was ugly when
ran on Windows 7, look scratchy.
I researched the code about the font for long time, it used DrawString
method to draw the text string, but i did not how to correct it, can anyone
correct it?

Author
27 Apr 2010 2:50 PM
PvdG42
"yxq" <ga***@163.net> wrote in message
news:uRGrWgf5KHA.5016@TK2MSFTNGP02.phx.gbl...
> I found a good article about the disk explorer
> http://www.codeproject.com/KB/vb/Disk_Size_Explorer.aspx
>
> And it ran well on Windows XP, but the text font on the chart was ugly
> when ran on Windows 7, look scratchy.
> I researched the code about the font for long time, it used DrawString
> method to draw the text string, but i did not how to correct it, can
> anyone correct it?
>

Every overload of the DrawString method specifies a Font object as the
second argument. Research the Font class here:

http://msdn.microsoft.com/en-us/library/system.drawing.font.aspx

and you should be able to change the font to something that looks better.
Author
27 Apr 2010 10:10 PM
yxq
I have changed the font to the specified Aril, regular, but the shown font
like bold and irregular, i think maybe the GDI+ caused the problem or there
are some changes from XP to Windows 7.

Show quoteHide quote
>
> "yxq" <ga***@163.net> wrote in message
> news:uRGrWgf5KHA.5016@TK2MSFTNGP02.phx.gbl...
>> I found a good article about the disk explorer
>> http://www.codeproject.com/KB/vb/Disk_Size_Explorer.aspx
>>
>> And it ran well on Windows XP, but the text font on the chart was ugly
>> when ran on Windows 7, look scratchy.
>> I researched the code about the font for long time, it used DrawString
>> method to draw the text string, but i did not how to correct it, can
>> anyone correct it?
>>
>
> Every overload of the DrawString method specifies a Font object as the
> second argument. Research the Font class here:
>
> http://msdn.microsoft.com/en-us/library/system.drawing.font.aspx
>
> and you should be able to change the font to something that looks better.
>
>
Author
28 Apr 2010 1:13 AM
Herfried K. Wagner [MVP]
Am 28.04.2010 00:10, schrieb yxq:
> I have changed the font to the specified Aril, regular, but the shown font
> like bold and irregular, i think maybe the GDI+ caused the problem or there
> are some changes from XP to Windows 7.

Maybe ClearType was turned off on the Windows XP machine and is turned
on on the Windows 7 machine.  If this is the case, you'd have to adjust
the drawing code.  When drawing the same string onto a certain surface
more than once, the ClearType subpixel colors add up, which leads to a
horribly looking result.  You can solve this problem by redrawing the
background prior to drawing the string.

--
  M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
28 Apr 2010 12:50 PM
yxq
Thank you, i think you are right.
"You can solve this problem by redrawing the background prior to drawing the
string.", i do not understand your meaning, could you please tell the
details?


Show quoteHide quote
> Am 28.04.2010 00:10, schrieb yxq:
>> I have changed the font to the specified Aril, regular, but the shown
>> font
>> like bold and irregular, i think maybe the GDI+ caused the problem or
>> there
>> are some changes from XP to Windows 7.
>
> Maybe ClearType was turned off on the Windows XP machine and is turned on
> on the Windows 7 machine.  If this is the case, you'd have to adjust the
> drawing code.  When drawing the same string onto a certain surface more
> than once, the ClearType subpixel colors add up, which leads to a horribly
> looking result.  You can solve this problem by redrawing the background
> prior to drawing the string.
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
28 Apr 2010 5:43 PM
Herfried K. Wagner [MVP]
Am 28.04.2010 14:50, schrieb yxq:
> Thank you, i think you are right.
> "You can solve this problem by redrawing the background prior to drawing the
> string.", i do not understand your meaning, could you please tell the
> details?

For example, fill the rectangle the text occupies with the background color.

Relevant methods:

'Graphics.MeasureString'
'Graphics.FillRectangle'
'Graphics.DrawString'

--
  M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
29 Apr 2010 12:11 PM
yxq
OK, i will try it, thank you.

"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at>
??????:esJk%23ov5KHA.5***@TK2MSFTNGP06.phx.gbl...
Show quoteHide quote
> Am 28.04.2010 14:50, schrieb yxq:
>> Thank you, i think you are right.
>> "You can solve this problem by redrawing the background prior to drawing
>> the
>> string.", i do not understand your meaning, could you please tell the
>> details?
>
> For example, fill the rectangle the text occupies with the background
> color.
>
> Relevant methods:
>
> 'Graphics.MeasureString'
> 'Graphics.FillRectangle'
> 'Graphics.DrawString'
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
30 Apr 2010 12:26 PM
yxq
I have solved the problem by add the line below
  'Graphics.TextRenderingHint =
System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit
Thank Herfried K. Wagner

Show quoteHide quote
> OK, i will try it, thank you.
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at>
> ??????:esJk%23ov5KHA.5***@TK2MSFTNGP06.phx.gbl...
>> Am 28.04.2010 14:50, schrieb yxq:
>>> Thank you, i think you are right.
>>> "You can solve this problem by redrawing the background prior to drawing
>>> the
>>> string.", i do not understand your meaning, could you please tell the
>>> details?
>>
>> For example, fill the rectangle the text occupies with the background
>> color.
>>
>> Relevant methods:
>>
>> 'Graphics.MeasureString'
>> 'Graphics.FillRectangle'
>> 'Graphics.DrawString'
>>
>> --
>>  M S   Herfried K. Wagner
>> M V P  <URL:http://dotnet.mvps.org/>
>>  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
>
>