Re: [Q]How to display Tahoma italic font



Thanks John and sorry that i forgot to describe more clearly.
First, the improper display is not that the middle italic letters
overlap the right hand normal letters, instead, it is that the middle
right hand normal letters overlap the last italic letter.
And what troubles me is that:
1. this program works well for other TT fonts except for the following:
"Arial Black"
"Comic Sans MS"
"Haettenschweiler"
"Impact"
"Lucida Console"
"Microsoft Sans Serif"
"Symbol"
"Tahoma"
"Times New Roman MT Extra Bold"
2. Instead of substracting the cWidth from the Xincrement, if I add the
cWidth, it will ok, but for other TT fonts, there are additional spaces
on the canvas. And I can't find anything to support adding the cWidth,
most of them suggest substracting like yours.

Thank you again and please find my comments inlined.

John Carson wrote:
"Johnny" <johnny194@xxxxxxxxxxx> wrote in message
*snip*
LPSTR lpszString = "dd";
int stringLen = strlen(lpszString);
LPWSTR wString = (LPWSTR)malloc(WCHAR_STRING_LENGTH * sizeof(LPWSTR));

So what is WCHAR_STRING_LENGTH? This doesn't make sense on several levels.
First, I don't know why you are converting from ANSI to Unicode instead of
starting out with Unicode. Second sizeof(LPWSTR) is just the size of a
pointer which has nothing to do with how much space you need for the string.
Third, you have not made any allowance for the terminating NUL. The
following makes more sense:

LPWSTR wString = (LPWSTR)malloc(sizeof(WCHAR) * (stringLen+1));

In fact, I don't know how to start out with Unicode. :( would you mind
to give me a brief example? And I changed
LPWSTR wString = (LPWSTR)malloc(WCHAR_STRING_LENGTH * sizeof(LPWSTR));
to
LPWSTR wString = (LPWSTR)malloc(sizeof(WCHAR) * (stringLen+1));
Thanks for your suggestion

*snip*
MultiByteToWideChar(CP_ACP, 0, lpszString, stringLen, wString,
WCHAR_STRING_LENGTH);

Change WCHAR_STRING_LENGTH to stringLen+1.
Done, thanks

*snip*
TextOut(hdc, XIncrement, YStart, (LPCWSTR)wString, stringLen);

Make that TextOutW (unless UNICODE is #defined, in which cas you don't need
all your other Ws).
I've changed all the TextOut to TextOutW, thanks

*snip*

Regards,
Johnny

.