为什么使用 Direct X 渲染斜体文本时某些字符没有完全显示
我正在使用 ID3DXFont::DrawText 渲染一些斜体文本。虽然我指定了 DT_NOCLIP 并且矩形足够大,但通常但不仅如此,文本的最后一个字符没有完全显示,而是从右侧剪切。
原因是什么?我该如何解决?有什么想法吗?
I am rendering some italic text using ID3DXFont::DrawText. Although i specify DT_NOCLIP and the rectangle is big enough, usually, but not only, last character of the text isn't show completely, but it is rather cut from its right side.
What can be the reason and how can I fix it? Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是 ID3DFont 类中的常见故障,并且无法解决(据我所知)。当字符具有不同的字符宽度和渲染宽度时,它不会计算真实的矩形面积,主要是在计算完整句子的总矩形面积时。
此外,罕见的字体(具有与其他字符重叠的渲染矩形)也肯定会被剪切。
其他故障包括字距调整对,因为它根本不关心它们。经典的 AV 示例将被渲染为中间有一个空白区域。
因此,最好的解决方案是避免 ID3DFont,并为自己编写文本渲染器,或使用 DirectWrite 等其他替代方案。
http://msdn.microsoft.com/en -us/library/dd368038%28v=vs.85%29.aspx
This is a common malfunction in the ID3DFont class, and it is not solventable (as I know of). It doesn't calculate real rectangle areas when characters have different character width and render width, mainly when calculating total rectangle area of a complete sentence.
Also rare fonts (that have render rectangles the overlap other characters) will be cut for sure too.
Other malfunctions include kerning pairs, as it simply doesn't care about them. The classic AV example will be rendered as if it had a white space in the middle.
Because of this, the best solution is to avoid ID3DFont, and code yourself a text renderer, or use other alternatives like DirectWrite.
http://msdn.microsoft.com/en-us/library/dd368038%28v=vs.85%29.aspx
这可能是别名问题?也许矩形实际上不够大?
不过,您应该发布一些代码和问题的屏幕截图......
It could be an aliasing issue? Perhaps the rectangle isn't actually big enough?
You should post some code and a screenshot of the problem though...