I3D3XFont::DrawTextW - 扩展选项卡错误?
我想知道这是否是 I3D3XFont::DrawTextW
的问题,我向它传递了一个包含 \t
的字符串,它会扩展该字符串。然而,它并不总是正确地做到这一点。如果我打印传递给它的相同字符串,选项卡将正确展开。例如,
dxfont->DrawTextW(NULL, msg, wcslen(msg), &textbox,
DT_LEFT | DT_TOP | DT_EXPANDTABS, D3DCOLOR_ARGB(255, 180, 180, 180));
Where msg is create 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,当打印到控制台时显示为:
Bamrow<4x tab>0<2x tab>0<2x tab>N/A<2x tab>2
但是,DrawTextW 将其显示为
Bamrow<5x tab>0<2x tab>0<2x tab>N/A<2x tab>2
是否有其他人遇到此问题和/或知道解决方案?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘿,抱歉。修好了。我需要根据单词的像素长度而不是有多少个字符来调整选项卡的比例。 GetTextExtent32W 成功了。
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.