Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

xegoth

Why can't I use a string variable for logtext?

This topic is 5111 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to define a font using logfont but its not letting me use a string variable. Heres what happens:

char sString[32];

LOGFONT LogFont = {72,0,0,0,FW_NORMAL,false,false,false,DEFAULT_CHARSET,
	OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH, sString};
I get the error: error C2440: ''initializing'' : cannot convert from ''char []'' to ''char'' I looked up the defintion of the logfont struct and theirs is an array of chars also (a string). the following works:
LOGFONT LogFont = {72,0,0,0,FW_NORMAL,false,false,false,DEFAULT_CHARSET,
	OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH, "Arial"};
What do I need to do to feed it a variable instead of a straight string? Note LOGFONT can be found in windows.h or wingdi.h

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Try this:

char sString[32];

LOGFONT LogFont = {72,0,0,0,FW_NORMAL,false,false,false,DEFAULT_CHARSET,
OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_PITCH, (char *)sString};

Share this post


Link to post
Share on other sites
Nope, unfortunately that doesn''t work. engine.cpp(126) : error C2440: ''initializing'' : cannot convert from ''char *'' to ''char''

The problem as I see it is microsoft declared the string in their struct as:

#define LF_FACESIZE 32

typedef struct tagLOGFONTA
{
LONG lfHeight;
LONG lfWidth;
LONG lfEscapement;
LONG lfOrientation;
LONG lfWeight;
BYTE lfItalic;
BYTE lfUnderline;
BYTE lfStrikeOut;
BYTE lfCharSet;
BYTE lfOutPrecision;
BYTE lfClipPrecision;
BYTE lfQuality;
BYTE lfPitchAndFamily;
CHAR lfFaceName[LF_FACESIZE];
}

as far as I can tell if they had done char* lfFaceName;
it would work, but they didn''t. So how can I send it a string variable without changing microsoft files

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!