mail-archives/mono-bugs/2006-February/039027.html

195 строки
7.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 77496][Blo] New - MeasureCharacterRanges
inconsistent with actual position
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%2077496%5D%5BBlo%5D%20New%20-%20MeasureCharacterRanges%0A%09inconsistent%20with%20actual%20position&In-Reply-To=bug-77496%40chernobyl.ximian.com">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="039026.html">
<LINK REL="Next" HREF="039028.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 77496][Blo] New - MeasureCharacterRanges
inconsistent with actual position</H1>
<B>bugzilla-daemon at bugzilla.ximian.com</B>
<A HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%2077496%5D%5BBlo%5D%20New%20-%20MeasureCharacterRanges%0A%09inconsistent%20with%20actual%20position&In-Reply-To=bug-77496%40chernobyl.ximian.com"
TITLE="[Mono-bugs] [Bug 77496][Blo] New - MeasureCharacterRanges
inconsistent with actual position">bugzilla-daemon at bugzilla.ximian.com
</A><BR>
<I>Tue Feb 7 16:08:11 EST 2006</I>
<P><UL>
<LI>Previous message: <A HREF="039026.html">[Mono-bugs] [Bug 77387][Blo] Changed - Cannot compile the
1.1.13.2_0 source files on Linux Mandrake 9.0, x86
</A></li>
<LI>Next message: <A HREF="039028.html">[Mono-bugs] [Bug 77496][Blo] Changed - MeasureCharacterRanges
inconsistent with actual position
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#39027">[ date ]</a>
<a href="thread.html#39027">[ thread ]</a>
<a href="subject.html#39027">[ subject ]</a>
<a href="author.html#39027">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">pkwan at advsofteng.net.</A>
<A HREF="http://bugzilla.ximian.com/show_bug.cgi?id=77496">http://bugzilla.ximian.com/show_bug.cgi?id=77496</A>
--- shadow/77496 2006-02-07 16:08:11.000000000 -0500
+++ shadow/77496.tmp.31711 2006-02-07 16:08:11.000000000 -0500
@@ -0,0 +1,121 @@
+Bug#: 77496
+Product: Mono: Class Libraries
+Version: 1.1
+OS: GNU/Linux [Other]
+OS Details: Fedore 4 and Gentoo (kernel 2.6.14) and probably other Linux too
+Status: NEW
+Resolution:
+Severity:
+Priority: Blocker
+Component: Sys.Drawing.
+AssignedTo: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">jordi at ximian.com</A>
+ReportedBy: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">pkwan at advsofteng.net</A>
+QAContact: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at ximian.com</A>
+TargetMilestone: ---
+URL:
+Cc:
+Summary: MeasureCharacterRanges inconsistent with actual position
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+
+Description of Problem:
+
+When drawing text using Graphics.DrawString, the position of the text as
+reported by MeasureCharacterRanges is different from the actual position
+rendered. This cause problems in softwares that need to know the positions
+of the text for automatic layout.
+
+Steps to reproduce the problem:
+
+1. Run the ASP.NET page below. This page is modified by code published in
+Microsoft's web site to explain how to use MeasureCharacterRanges. It
+draws text on a Bitmap object, then draws the bounding rectangle to the
+text.
+
+Actual Results:
+
+In Microsoft.NET, the bounding rectangle correctly bounds the text. In
+Mono, part of the text is outside the bounding rectangle. The bounding
+rectangle appears to be in a reasonably correct position, so the text
+position is incorrect.
+
+Expected Results:
+
+That the bounding rectangle should bound that text, and that the top edge
+of the rectangle should be close to the top edge of the bitmap, as the
+text is drawn at (0, 0).
+
+How often does this happen?
+
+Always in Mono 1.1.13_2 and also seen in Mono 1.1.12.
+
+Additional Information:
+
+Test code as follows:
+
+
+&lt;%@ Page language=&quot;c#&quot; Debug=&quot;true&quot; %&gt;
+&lt;%@ Import Namespace=&quot;System.Drawing&quot; %&gt;
+&lt;%@ Import Namespace=&quot;System.Drawing.Text&quot; %&gt;
+&lt;%@ Import Namespace=&quot;System.Drawing.Imaging&quot; %&gt;
+&lt;%
+// Set up string.
+string measureString = &quot;ABpqr and xyz123 ranges&quot;;
+Font stringFont = new Font(&quot;Arial&quot;, 12.0F);
+
+// Set character ranges to measure
+CharacterRange[] characterRanges = { new CharacterRange(0, 5), new
+CharacterRange(10, 6) };
+
+// Create rectangle for layout.
+float x = 0F;
+float y = 0F;
+float width = 250.0F;
+float height = 35.0F;
+RectangleF layoutRect = new RectangleF(x, y, width, height);
+
+// Set string format.
+StringFormat stringFormat = new StringFormat();
+stringFormat.SetMeasurableCharacterRanges(characterRanges);
+
+// Draw to bitmap
+Bitmap b = new Bitmap((int)width, (int)height);
+b.SetResolution(96, 96);
+Graphics g = Graphics.FromImage(b);
+g.DrawString(measureString, stringFont, Brushes.Black, x, y, stringFormat);
+
+// Measure two ranges in string.
+Region[] stringRegions = new Region[2];
+stringRegions = g.MeasureCharacterRanges(measureString, stringFont,
+layoutRect, stringFormat);
+
+// Draw rectangle for first measured range.
+RectangleF measureRect1 = stringRegions[0].GetBounds(g);
+g.DrawRectangle(new Pen(Color.Red, 1), Rectangle.Round(measureRect1));
+
+// Draw rectangle for second measured range.
+RectangleF measureRect2 = stringRegions[1].GetBounds(g);
+g.DrawRectangle(new Pen(Color.Blue, 1), Rectangle.Round(measureRect2));
+
+//Render pixels in bitmap as cells in HTML table below
+%&gt;
+&lt;TABLE CELLSPACING='0' CELLPADDING='0' BORDER='1'&gt;&lt;TR&gt;&lt;TH&gt;&lt;/TH&gt;
+&lt;% for (int i = 0; i &lt; b.Width; ++i) { %&gt;&lt;TH WIDTH=&quot;20&quot;
+BGCOLOR='#DDDDDD'&gt;&lt;%=i%&gt;&lt;/TH&gt;&lt;% } %&gt;
+&lt;%
+ for (int i = 0; i &lt; b.Height; ++i)
+ {
+%&gt;
+&lt;TR&gt;&lt;TD BGCOLOR='#DDDDDD'&gt;&lt;%=i%&gt;&lt;/TD&gt;
+&lt;%
+ for (int j = 0; j &lt; b.Width; ++j)
+ {
+%&gt;
+&lt;TD bgcolor='&lt;%=b.GetPixel(j, i).A == 0 ? &quot;#FFFFFF&quot; : &quot;#000000&quot;%
+&gt;'&gt;&amp;nbsp;&lt;/TD&gt;
+&lt;%
+ }
+ }
+%&gt;
+&lt;/TABLE&gt;
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="039026.html">[Mono-bugs] [Bug 77387][Blo] Changed - Cannot compile the
1.1.13.2_0 source files on Linux Mandrake 9.0, x86
</A></li>
<LI>Next message: <A HREF="039028.html">[Mono-bugs] [Bug 77496][Blo] Changed - MeasureCharacterRanges
inconsistent with actual position
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#39027">[ date ]</a>
<a href="thread.html#39027">[ thread ]</a>
<a href="subject.html#39027">[ subject ]</a>
<a href="author.html#39027">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-bugs">More information about the mono-bugs
mailing list</a><br>
</body></html>