GraphicsPath.AddString(const WCHAR*, INT, const FontFamily*, INT, REAL, const PointF, const StringFormat*) method

Applies to: desktop apps only

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, ref]  const PointF &origin,
  [in]       const StringFormat *format
);

Parameters

  • string [in]
    Type: const WCHAR*

    Pointer to a wide-character string.

  • length [in]
    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 [in]
    Type: const FontFamily*

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

  • style [in]
    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 [in]
    Type: REAL

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

  • origin [in, ref]
    Type: const PointF

    Reference to a PointF object that specifies, in world units, the location of the string.

  • format [in]
    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, 
      PointF(50.0f, 50.0f),
      NULL);

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

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdipluspath.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

GraphicsPath

AddString Methods

Font

FontFamily

FontStyle

StringFormat

PointF

Clipping with a Region

Constructing and Drawing Paths

Creating a Path Gradient

Using Text and Fonts

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012