开发者

How do I display same "proportional" text size on different resolutions?

I draw some text on screen using ID3DXFont::DrawText. This text should be displayed the same regardless of screen resolution.

For example, if开发者_运维问答 screen resolution is low, text wrapped and when it is higher text is not wrapped. How can I avoid such situation? I want text size to be connected to screen resolution so if resolution is lower I want the text to be relatively smaller so that no wrapping happens. Is there any way?

Thanks in advance


Below is a logical solution. It doesn't have any of the code or procedures needed to make work in direct X but having done something similar outside of DirectX I wanted to share the logic

  1. Working on whatever default screen resolution you want set the font to be the size needed.
  2. Find the percentage of the screen height the font size you chose takes up.
  3. Then having stored that value when you go to render again, in the final version of the program, calculate the font size based on the screen size and the percentage

What I was working in had functions like GetTextHeight and properties on the font size to allow you to set the height (which in turn set the font size appropriately). So if can find anything similar to this in DirectX than this could be a route for you to take.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜