title: drawstring rotate long text 180
body: <p>I use drawstring method to draw text inside rectangle ,.. i wanted to rotate the text 180 degree so i used this code </p>
  
  <pre><code>   Rectangle displayRectangleh =
         new Rectangle(new Point((int)posh.X, (int)posh.Y), new Size(rectwdh, recth));
  
     StringFormat format1h = new StringFormat(StringFormatFlags.DirectionVertical);
     format1h.LineAlignment = StringAlignment.Center;
     format1h.Alignment = StringAlignment.Center;
     b = new SolidBrush(Color.Black);
     e.ChartGraphics.Graphics.TranslateTransform((float)rectwdh / 2 + posh.X, recth / 2 + posh.Y);
     e.ChartGraphics.Graphics.RotateTransform(180);
     e.ChartGraphics.Graphics.TranslateTransform(-((float)rectwdh / 2 + posh.X), -(recth / 2 + posh.Y));
              Font boldFonth = new Font(FontFamily.GenericSansSerif, 16, FontStyle.Bold, GraphicsUnit.Pixel, 1, true);
     e.ChartGraphics.Graphics.DrawRectangle(new Pen(Color.Black, 2), displayRectangleh);
     e.ChartGraphics.Graphics.DrawString("This is rotated long text test ", boldFonth, b, (RectangleF)displayRectangleh, format1h);
     e.ChartGraphics.Graphics.ResetTransform();
  </code></pre>
  
  <p>where posh.X and posh.Y (recatangle position) , rectwdh (rectangle width) and recth (rectangle height)</p>
  
  <p>It works perfect for short text but for long text the new line will be above my old line see the next pic :</p>
  
  <p><a href="https://i.stack.imgur.com/rXIsn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rXIsn.png" alt="enter image description here"></a></p>
  
  <p>I even tried to add new line character \n but same result.
  my question : how to rotate the text 180 inside rectangle and end up with proper alignment ??</p>