Archived

This topic is now archived and is closed to further replies.

dansteph

CD3DFONT BUG correction here---> (free enter)

Recommended Posts

dansteph    122
cd3dfont is fast but is buggy with big font there is artifact with the "i" "I" "l" "L" letter. Correction is really simple: In: d3dfont.cpp
//in the function:
HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice ){}

//change the line :
x += size.cx+1;

//by :
// Correction 73=I 76=L 105=i 108=l
if(c==73||c==76||c==105||c==108)	
  x += 2*size.cx+1;
else
  x += size.cx+1;

//Now the loop should look like this:

for( TCHAR c=32; c<127; c++ )
{
   str[0] = c;
   GetTextExtentPoint32( hDC, str, 1, &size );

   if( (DWORD)(x+size.cx+1) > m_dwTexWidth )
   {
      x  = 0;
      y += size.cy+1;
   }

   ExtTextOut( hDC, x+0, y+0, ETO_OPAQUE, NULL, str, 1, NULL );

   m_fTexCoords[c-32][0] = ((FLOAT)(x+0))/m_dwTexWidth;
   m_fTexCoords[c-32][1] = ((FLOAT)(y+0))/m_dwTexHeight;
   m_fTexCoords[c-32][2] = ((FLOAT)(x+0+size.cx))/m_dwTexWidth;
   m_fTexCoords[c-32][3] = ((FLOAT)(y+0+size.cy))/m_dwTexHeight;

   // Correction 73=I 76=L 105=i 108=l
   if(c==73||c==76||c==105||c==108)	
      x += 2*size.cx+1;
   else
      x += size.cx+1;
}
 
Now big font doesn't have anymore artifact... It seem also that in some case other letter can cause trouble (v?) in this case just add their number in the if statement. Dan Edited by - dansteph on November 10, 2001 12:35:31 PM

Share this post


Link to post
Share on other sites
CrazedGenius    156
another way might just be to add a little space to every character, because there might be some fonts that mess up on other letters. I just do this:

x += size.cx+10;

A little more in the way of wasted pixels, but not really. If you look at the full texture, there is usually alot wasted anyway. You probably break even and you don''t have to hard code specific characters.

Share this post


Link to post
Share on other sites