开发者

I3D3XFont::DrawTextW - Expanding tabs wrong?

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?开发者_如何学编程


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜