0

I'm wondering if it's an issue with I3D3XFont::DrawTextW, I pass it a string with \t in it, which it expands. However, it doesn't always do it correctly. If I print the same string that I pass to it, the tabs are expanded correctly. For example,

dxfont->DrawTextW(NULL, msg, wcslen(msg), &textbox,
        DT_LEFT | DT_TOP | DT_EXPANDTABS, D3DCOLOR_ARGB(255, 180, 180, 180));

Where msg is created via:

swprintf_s(temp, sizeof(temp), L"%s\t\t\t\t%i\t\t%i\t\t%s\t\t%i\n",
        pList[x].name.c_str(), pList[x].kills, pList[x].deaths, wratio,
        pList[x].suicides);

Which, when printed to console comes out as:

Bamrow<4x tab>0<2x tab>0<2x tab>N/A<2x tab>2

But, DrawTextW displays it as

Bamrow<5x tab>0<2x tab>0<2x tab>N/A<2x tab>2

Has anyone else had this issue and/or knows a solution?

Kirill V. Lyadvinsky
  • 97,037
  • 24
  • 136
  • 212
  • That's a really strange transformation. Is it possible your capturing for analysis is munging the text? – wallyk Dec 04 '09 at 04:58
  • I don't think so. I have a row of text above that (for DrawText) which is spaced to 4 tabs correctly, and the output from this DrawText shows the data after the name one tab too far. I included <4x tab> etc because when I inserted a tab character it didn't show anything when posting the message. – DirectXFag Dec 04 '09 at 05:09
  • I'll elaborate a bit. I have two possible swprintf_s statements, shown below. if (len >= 8) swprintf_s(temp, sizeof(temp), L"%s\t\t\t%i\t\t%i\t\t%s\t\t%i\n", pList[x].name.c_str(), pList[x].kills, pList[x].deaths, wratio, pList[x].suicides); else swprintf_s(temp, sizeof(temp), L"%s\t\t\t\t%i\t\t%i\t\t%s\t\t%i\n", pList[x].name.c_str(), pList[x].kills, pList[x].deaths, wratio, pList[x].suicides); While this works for many names, if the person's name is comprised of capital letters, ie MEMEME, it will be spaced too far, whereas mememe would be spaced correctly. – DirectXFag Dec 04 '09 at 05:20

1 Answers1

0

Hey, sorry. Fixed it. I needed to ratio the tabs based on the pixel length of the word, not how many characters there are. GetTextExtent32W did the trick.