Jump to content
  • Advertisement
Sign in to follow this  
MeshMan

Bitmap Fonts

This topic is 4817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I'm trying to render bitmap fonts. I have a 256x256 TGA with an alpha channel with the characters tightly packed that comes along with a XML file detailing where each char starts on the XY and its width height, spacing etc.. I've verified the starting pixel locations in the XML files and the char width/height and its absoloutley perfect. However, when I try to render the characters using something like the following to generate the UV Coords for my quad: pVertices->u = (1.0f/m_TexWidth) * (ci.x); pVertices->v = (1.0f/m_TexHeight) * (ci.y); 'ci.x' being the starting XPos on the texture where the char starts. For some reason, I'm not getting pixel perfect quads :/ It works nicely for the first character in the top left corner of the texture, but then when I draw using characters further in the bitmap I'm getting where I get edges form the texture that shouldnt be in the char image. http://www.meshsoft.net/font.jpg - What it looks like. Can anyone tell me why it might be doing this? I've tried changing texture addressing mode to D3DTADDRESS_CLAMP but doesn't make a difference. Thanks, Meshy

Share this post


Link to post
Share on other sites
Advertisement
Hi,

You probably want to subtract half a texel to all of your texture coordinates that are mapped directly on screen space:

pVertices->u = (1.0f/m_TexWidth) * (ci.x) - (0.5f / m_TexWidth);
pVertices->v = (1.0f/m_TexHeight) * (ci.y) - (0.5f / m_TexHeight);

To make sure the right texel is covering the right pixel.

There is a section about it in the DirectX SDK, look for "Directly Mapping Texels to Pixels".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!