title: Properly draw text using GraphicsPath
body: <p>As you can see in the image below, the text on the PictureBox is different from the one in the TextBox. It is working alright if I use <code>Graphics.DrawString()</code> but when I use the Graphics Path, it truncates and doesn't show the whole text. What do you think is wrong in my code?</p>
  <p><a href="https://i.stack.imgur.com/Hxjj8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hxjj8.png" alt="enter image description here" /></a></p>
  <p>Here is my code:</p>
  <pre><code>public LayerClass DrawString(LayerClass.Type _text, string text, RectangleF rect, Font _fontStyle, PaintEventArgs e)
  {
      using (StringFormat string_format = new StringFormat())
      {
          rect.Size = e.Graphics.MeasureString(text, _fontStyle);
          rect.Location = new PointF(Shape.center.X - (rect.Width / 2), Shape.center.Y - (rect.Height / 2));
          if(isOutlinedOrSolid)
          {
              using (GraphicsPath path = new GraphicsPath())
              {
                  path.AddString(text, _fontStyle.FontFamily, (int)_fontStyle.Style, rect.Size.Height, rect, string_format);
                  e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                  e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
                  e.Graphics.CompositingMode = CompositingMode.SourceOver;
                  e.Graphics.DrawPath(new Pen(Color.Red, 1), path);
              }
          }
          else
          {
              e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
              e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
              e.Graphics.CompositingMode = CompositingMode.SourceOver;
              e.Graphics.DrawString(text,_fontStyle,Brushes.Red, rect.Location);
          }
      }
  
      this._Text = text;
      this._TextRect = rect;
      return new LayerClass(_text, this, text, rect);
  }
  </code></pre>