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 |
另请参阅
StringFormat
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈