all groups > dotnet drawing api > july 2007 >
You're in the

dotnet drawing api

group:

Bug in DrawString()


Bug in DrawString() Maruszek
7/21/2007 4:01:10 PM
dotnet drawing api:
I think I found a bug in Graphics.DrawString() method. Font underlines
and strikeouts are drawn in wrong places after changing
Graphics.PageUnit.

To reproduce this bug place provided code in the Paint event of a
form:
{
Font font = new Font("Arial", 10, FontStyle.Underline);
Graphics g = e.Graphics;
g.PageUnit = GraphicsUnit.Point;
g.DrawString("Hello World!", font, Brushes.Black, 50, 50);
g.PageUnit = GraphicsUnit.Pixel;
g.DrawString("Hello World!", font, Brushes.Black, 50, 50);
}

Results are different under .net 1.1 and 2.0 but in both cases they
are wrong.
Can someone please confirm this bug?

--
Wojciech Maruszek
Re: Bug in DrawString() Morten Wennevik [C# MVP]
7/22/2007 5:58:55 PM
On Sun, 22 Jul 2007 01:01:10 +0200, Maruszek <maruszek@gmail.com> wrote:=


[quoted text, click to view]

Hi,

I'm not sure this is a bug, and if it is, it isn't related to changing t=
he GraphicsUnit. The mismatched underline is drawn when you use PageUni=
t.Point. Even though you draw using PageUnit.Point first, the topmost t=
ext is in fact drawn using PageUnit.Pixel (use different brushes to see =
this).

Anyhow, why using PageUnit.Point creates such a difference between the t=
ext and its underline I don't know.

-- =

Happy coding!
AddThis Social Bookmark Button