GdipCreateFontFamilyFromName
first parameter expects a const WCHAR*
, how I could initialize the value of opt.fontName
with it?
struct GDImDrawText
{
HWND hWnd;
ARGB fontColor;
int fontSize;
int fontStyle = 0;
WCHAR* fontName; // <--- Do i need to use another data type? which?
int x = 0;
int y = 0;
int w;
int h;
};
//...
GDI gdip;
GDImDrawText opt;
opt.fontColor = 0xffffff;
opt.fontSize = 14;
opt.fontName = L"Tahoma"; // <--- ???
opt.hWnd = hWnd;
opt.x = 20;
gdip.mDrawText(g, opt);
//...
void GDI::mDrawText(GpGraphics* g, GDImDrawText opt)
{
GpFontFamily* fontFamily;
GdipCreateFontFamilyFromName(opt.fontName, 0, &fontFamily);
//...
}
Do I need to modify the declaration of fontName
into the struct?
WCHAR
is a wide character normally representing 16 bit instead of the default 8 bit of a char
. It is used eg to represent encoding standards like UTF-16 which can not be encoded with only 8 bits (like ASCII).
You initialized your wide char array
correctly by specifying it with the L
in front of the string. This tells the compiler that the string is in fact a wide char array
instead of a "normal" char array
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.