I3D3XFont::DrawTextW - 扩展选项卡错误?

发布于 2024-08-13 15:17:21 字数 806 浏览 5 评论 0原文

我想知道这是否是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北渚 2024-08-20 15:17:22

嘿,抱歉。修好了。我需要根据单词的像素长度而不是有多少个字符来调整选项卡的比例。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文