   Antialiased text rendering (D3DX9)
  Hi,I can't figure out how to render text at a decent quality, with D3DX.  I'm creating the font like this:// Unmanaged C++D3DXCreateFont(d3dDevice, pxSize, 0, (bold ? FW_BOLD : FW_NORMAL), 0, italics,   DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE,   fontface, &(pFont->d3dxfont));Then I render it with:    m_pD3DXSprite->Begin(D3DXSPRITE_OBJECTSPACE|D3DXSPRITE_ALPHABLEND);font.d3dxfont->DrawText(m_pD3DXSprite, text, -1, &rect, format, color);m_pD3DXSprite->End();The result looks pretty bad compared to drawing text in MS Paint:Any ideas what I'm doing wrong?  Why is the text coming out so knobbly and aliased even with ANTIALIASED_QUALITY set?Thanks for any help.   
  Try CLEARTYPE_QUALITY or PROOF_QUALITY for the Quality parameter. They should produce even better results. Check out the full description here.   ;  Ah, thanks.  Cleartype quality improves it - but it's still nowhere near as nice as with MS Paint.  Is it not possible to render text at that quality in DirectX?Here's how it looks now.  Note CLEARTYPE_QUALITY is better, but still not as good as MS Paint.;  You'll get superior results to anything that GDI can produce if you leverage the GPU in your favor.  The best way to do that is described in a paper by Jim Blinn and Charles Loop: Resolution Independent Curve Rendering using Programmable Graphics Hardware;  Interesting link legalize, but surely I would be reinventing the wheel?  Presumably MS Paint calls some GDI function that looks lovely, so why can't I get D3DX to do it that nicely?   ;  GDI doesn't natively support alpha.  Using GDI directly to draw text would be slow.  ID3DXFont works by grabbing glyphs from GDI and rasterizing them once using GDI into a texture.  The texture is then used for drawing the text, but it isn't re-rasterized at different sizes.  GDI re-rasterizes in software every time you change a parameter that controls font size (but not glyph spacing).  Reproducing all the font subtlety behaviors in ID3DXFont is tedious and can also impact performance.  ID3DXFont doesn't promise to get the same quality as GDI font rendering; it does remarkably well considering.  If you need exact GDI quality output, then I'd suggest that you use a system memory surface that is compatible with GDI, render text to that and then make a billboard texture from that surface yourself and draw the text with the billboard.However, all of that is going to be slower and at worse quality than the method presented by Blinn and Loop in that paper.  I would not be surprised if you see GDI's text rendering ultimately replaced with the Blinn and Loop algorithm, or a variant of it, at some point in the future as Vista and subsequent releases of Windows leverage the GPU more and more for desktop operations.   ;Quote:Original post by legalize[...] If you need exact GDI quality output, then I'd suggest that you use a system memory surface that is compatible with GDI, render text to that and then make a billboard texture from that surface yourself and draw the text with the billboard.Either that or you can construct a bitmapped font altogether if you can stick with one single size. Then you would have full control over the quality of characters.   ;Quote:Original post by staafQuote:Original post by legalize[...] If you need exact GDI quality output, then I'd suggest that you use a system memory surface that is compatible with GDI, render text to that and then make a billboard texture from that surface yourself and draw the text with the billboard.Either that or you can construct a bitmapped font altogether if you can stick with one single size. Then you would have full control over the quality of characters.This is what ID3DXFont does.   ;  Ah, yes, sorry. I was going more along the line of using an external program or way to create a high quality bitmap font specifically for the situation. It could be some work but if quality is a high priority it might also be worth it.Interesting article by the way legalize.   ;Quote:Original post by legalizeID3DXFont works by grabbing glyphs from GDI and rasterizing them once using GDI into a texture.I don't understand why this still results in poor quality text - doesn't it render each glyph with GDI (which should render glyphs at the same quality MS Paint does), then move them to a texture and render strings from the texture?  As in, effectively render it to a bitmap font in video memory.  Why would this result in poor quality text rendering, if it's using GDI?So is there no way for ID3DXFont to achieve MS Paint quality?  How do commercial games go about this?  And is there some kind of library someone's already written to do text rendering in decent quality?  I set out to draw text to the screen, and wasn't really expecting to have to design my own entire font rendering engine...   