[Mono-bugs] [Bug 79685][Nor] New - GdipDrawString does not align single character strings correctly.
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Tue Oct 17 13:39:57 EDT 2006
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 rolfkvinge at ya.com.
http://bugzilla.ximian.com/show_bug.cgi?id=79685
--- shadow/79685 2006-10-17 13:39:57.000000000 -0400
+++ shadow/79685.tmp.21593 2006-10-17 13:39:57.000000000 -0400
@@ -0,0 +1,84 @@
+Bug#: 79685
+Product: Mono: Class Libraries
+Version: 1.1
+OS: other
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: libgdiplus
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: rolfkvinge at ya.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: GdipDrawString does not align single character strings correctly.
+
+Single character strings are not aligned properly.
+
+Steps to reproduce the problem:
+1. Compile and run the code.
+
+Actual Results:
+The single character string is left-aligned.
+
+Expected Results:
+The single character string should be centered (just as the other string).
+
+How often does this happen?
+Always (Linux - MS works perfectly).
+
+Additional information:
+This makes MonthCalendar draw ugly days for the first 9 days in every
+month!
+
+Test case:
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace centered
+{
+ public class MainForm : Form
+ {
+ public MainForm ()
+ {
+ Paint += new PaintEventHandler (MainForm_Paint);
+ }
+
+ void MainForm_Paint (object sender, PaintEventArgs e)
+ {
+ using (StringFormat format = new StringFormat ()) {
+ format.Alignment = StringAlignment.Center;
+ format.LineAlignment = StringAlignment.Center;
+
+ Rectangle rect = this.ClientRectangle;
+ rect.Width /= 4;
+ rect.Height /= 4;
+ rect.Location = new Point ((int)(rect.Width *
+1.5), (int)(rect.Height));
+ e.Graphics.FillRectangle (Brushes.White,
+this.ClientRectangle);
+ e.Graphics.DrawRectangle (new
+Pen(Brushes.SpringGreen, 2), rect);
+ e.Graphics.DrawString ("a", this.Font,
+Brushes.SteelBlue, rect, format);
+
+ rect.Offset (0, (int)( rect.Height * 1.5));
+ e.Graphics.DrawRectangle (new Pen
+(Brushes.SpringGreen, 2), rect);
+ e.Graphics.DrawString ("aa", this.Font,
+Brushes.SteelBlue, rect, format);
+ }
+ }
+
+ [STAThread]
+ static void Main(string[] args)
+ {
+ Application.Run (new MainForm ());
+ }
+
+ }
+}
More information about the mono-bugs
mailing list