GraphicsPath::AddString method

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

Syntax

Status AddString(
  IN const WCHAR        *string,
  IN INT                length,
  IN const FontFamily   *family,
  IN INT                style,
  IN REAL               emSize,
  IN const RectF &      layoutRect,
  IN const StringFormat *format
);

Parameters

string

Type: const WCHAR*

Pointer to a wide-character string.

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.

family

Type: const FontFamily*

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

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.

emSize

Type: REAL

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

layoutRect

Type: const RectF

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

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: 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.

Remarks

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

Examples

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;

   path.AddString(
      L"Hello World", 
      -1,                 // NULL-terminated string
      &fontFamily, 
      FontStyleRegular, 
      48, 
      RectF(50.0f, 50.0f, 150.0f, 100.0f),
      NULL);

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

Requirements

   
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

Font

FontFamily

FontStyle

GraphicsPath

RectF

StringFormat

Using Text and Fonts