Adds a string.
Syntax

[C#]

void AddString(string text, Font font, RectangleF rect, stringFormat format);
void AddString(string text, FontFamily family, int style, double emSize, PointF origin, stringFormat format);
void AddString(string text, FontFamily family, int style, double emSize, RectangleF rect, stringFormat format);

[Visual Basic]

Sub AddString(text As String, font As Font, rect As RectangleF, format As StringFormat)
Sub AddString(text As String, family As FontFamily, style As Integer, emSize As Double, origin As PointF, format As StringFormat)
Sub AddString(text As String, family As FontFamily, style As Integer, emSize As Double, rect As RectangleF, format As StringFormat)
Params
Name Description
text The text.
font The family.
style The style.
emSize The em size.
rect The rectangle.
format The format.
family The family.
origin The origin.
Notes

None.

Example

[C#]

using (Bitmap bm = new Bitmap(600, 600)) {
  using (Graphics graphics = Graphics.FromImage(bm)) {
    RectangleF rect = bm.Bounds;
    rect.Inflate(-50, -50);
    GraphicsPath path = new GraphicsPath();
    StringFormat format = new StringFormat();
    format.Alignment = StringAlignment.Center;
    format.LineAlignment = StringAlignment.Center;
    Font font = new Font(FontFamily.GenericSerif, 500, FontStyle.Regular, GraphicsUnit.Pixel);
    graphics.DrawString("Ti", font, Brushes.Green, rect, format);
    path.AddString("Ti", font, rect, format);
    Pen pen = new Pen(Color.Red, 5);
    graphics.DrawPath(pen, path);
  }
  bm.Save(Server.MapPath("IG8_GraphicsPath_AddString.png"));
}


The code here draws some text into a GraphicsPath. We draw the same text onto a Bitmap in green. Then we use the vector outline in GraphicsPath to outline the text in red. The final output is shown below.


IG8_GraphicsPath_AddString.png