DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
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:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us