Archived

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

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

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

Recommended Posts

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 on other sites
what is wrong with my code tag ? it doesn''t display the nice white background ?

Dan

Share on other sites
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 on other sites
the nice white background is the source tag, not code.