|
|
|
start date: Sat, 21 Jul 2007 16:01:10 -0700,
posted on: microsoft.public.dotnet.framework.drawing
back
| Thread Index |
|
1
Maruszek
|
|
2
Morten Wennevik [C# MVP]
|
Bug in DrawString()
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
Date:Sat, 21 Jul 2007 16:01:10 -0700
Author:
|
Re: Bug in DrawString()
On Sun, 22 Jul 2007 01:01:10 퍭, Maruszek wrote:> 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
>
>
Hi,
I'm not sure this is a bug, and if it is, it isn't related to changing the GraphicsUnit. The mismatched underline is drawn when you use PageUnit.Point. Even though you draw using PageUnit.Point first, the topmost text is in fact drawn using PageUnit.Pixel (use different brushes to see this).
Anyhow, why using PageUnit.Point creates such a difference between the text and its underline I don't know.
-- Happy coding!
Morten Wennevik [C# MVP]
Date:Sun, 22 Jul 2007 17:58:55 +0200
Author:
|
|
|