Sign in to follow this  

Letters clipped for some italic fonts

This topic is 3488 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

I'm finding that when certain italic fonts (such as "Wide Latin") are drawn using DrawText, some of the letters appear cut off. Does anyone have any ideas regarding what the problem could be? Any help would be appreciated.
D3DXCreateFont(m_pd3dDevice, nHeight, 0, FW_NORMAL, 0, TRUE, DEFAULT_CHARSET, 
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Wide Latin", &m_pFont);
RECT rc;
SetRect( &rc, 150, 200, 500, 500 ); 

m_pFont->DrawText( NULL, L"ID3DXFont::DrawText", -1, &rc, DT_NOCLIP, D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f ));
This is what I'm seeing: Image Hosted by ImageShack.us

Share this post


Link to post
Share on other sites
You probably just need to turn on alphablending, to prevent the next letter's black area from covering the previous letter.

You'll need to pass a Sprite object that you create to the DrawText method. Before calling DrawText, make sure you call ID3DXSprite::Begin() with the AlphaBlending flag.

Hope this helps.

Share this post


Link to post
Share on other sites
Thanks for your suggestion, unfortunately I've tried the following and it doesn't fix the issue.


m_pTextSprite->Begin( D3DXSPRITE_ALPHABLEND);
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );

m_pFont->DrawText( m_pTextSprite, L"ID3DXFont::DrawText", -1, &rc, DT_NOCLIP, D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f ));
pTextSprite->End();

Share this post


Link to post
Share on other sites
Quote:
Original post by Anon Mike
A previous time this came up...
Only partially related though [smile]

That was using my own font renderer, not ID3DXFont. I believe ID3DXFont can't cope with it - it just doesn't render the correct sized glyph to the texture it uses internally.
So, you can either live with it, or go totally overboard and write your own font renderer like I did. I'm happy to post my code here, but it's fairly engine specific, so the general algorithm will only be useful, the code won't really drop into existing code [smile]

Share this post


Link to post
Share on other sites

This topic is 3488 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this