GraphicsPath::AddString (constWCHAR*,INT,constFontFamily*,INT,REAL,constPointF&,constStringFormat*) 方法 (gdipluspath.h)

GraphicsPath::AddString 方法将字符串的轮廓添加到此路径。

语法

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

参数

string

指向宽字符字符串的指针。

length

指定要显示的字符数的整数。 如果字符串参数指向以 NULL 结尾的字符串,则可以将此参数设置为 –1。

family

指向 FontFamily 对象的指针,该对象指定字符串的字体系列。

style

指定字样样式的整数。 此值必须是 FontStyle 枚举的元素,或者是应用于其中两个或更多个元素的按位 OR 的结果。 例如, FontStyleBold | FontStyleUnderline | FontStyleStrikeout 将样式设置为三种样式的组合。

emSize

指定字符串字符的 em 大小的实数(以世界单位为单位)。

origin

PointF 对象的引用,该对象以世界单位指定字符串的位置。

format

指向 StringFormat 对象的指针,该对象指定布局信息 (字符串的对齐、剪裁、制表位等) 。

返回值

类型:状态

如果该方法成功,则返回 Ok,这是 Status 枚举的元素。

如果方法失败,它将返回 Status 枚举的其他元素之一。

注解

请注意,GDI+ 不支持没有 TrueType 轮廓的 PostScript 字体或 OpenType 字体。

示例

以下示例创建 一个 GraphicsPath 对象路径,将一个以 NULL 结尾的字符串添加到 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);
}

要求

   
标头 gdipluspath.h

另请参阅

AddString 方法

使用区域进行剪裁

构造并绘制轨迹

创建路径渐变

字体

FontFamily

FontStyle

GraphicsPath

PointF

StringFormat

使用文本和字体