GraphicsPath::AddString(constWCHAR*,INT,constFontFamily*,INT,REAL,constRectF&,constStringFormat*) method (gdipluspath.h)

The GraphicsPath::AddString method adds the outline of a string to this path.


Status AddString(
  [in]      const WCHAR        *string,
  [in]      INT                length,
  [in]      const FontFamily   *family,
  [in]      INT                style,
  [in]      REAL               emSize,
  [in, ref] const RectF &      layoutRect,
  [in]      const StringFormat *format


[in] string

Type: const WCHAR*

Pointer to a wide-character string.

[in] length

Type: INT

Integer that specifies the number of characters to display. If the string parameter points to a NULL-terminated string, this parameter can be set to –1.

[in] family

Type: const FontFamily*

Pointer to a FontFamily object that specifies the font family for the string.

[in] style

Type: INT

Integer that specifies the style of the typeface. This value must be an element of the FontStyle enumeration or the result of a bitwise OR applied to two or more of these elements. For example, FontStyleBold | FontStyleUnderline | FontStyleStrikeout sets the style as a combination of the three styles.

[in] emSize

Type: REAL

Real number that specifies the em size, in world units, of the string characters.

[in, ref] layoutRect

Type: const RectF

Reference to a RectF object that specifies, in world units, the bounding rectangle for the string.

[in] format

Type: const StringFormat*

Pointer to a StringFormat object that specifies layout information (alignment, trimming, tab stops, and the like) for the string.

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.


Note that GDI+ does not support PostScript fonts or OpenType fonts which do not have TrueType outlines.


The following example creates a GraphicsPath object path, adds a NULL-terminated string to path, and then draws path.

VOID Example_AddString(HDC hdc)
   Graphics graphics(hdc);
   FontFamily fontFamily(L"Times New Roman");
   GraphicsPath path;

      L"Hello World", 
      -1,                 // NULL-terminated string
      RectF(50.0f, 50.0f, 150.0f, 100.0f),

   Pen pen(Color(255, 255, 0, 0));
   graphics.DrawPath(&pen, &path);


Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdipluspath.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

AddString Methods

Clipping with a Region

Constructing and Drawing Paths

Creating a Path Gradient







Using Text and Fonts