Rendering anti-aliased smooth text

Hello,
      I searched for a way to render an anti-aliased smooth ( and with a ClearType) text, But I didn't find . I want also to add a shadow to the font
Thanks,
Mustafa ELBanna


Answer this question

Rendering anti-aliased smooth text

  • Bdenison

    It's been a while since I've tried it, but off the top of my head it's the D3DXCreateFont( ) params that you want to be looking at. It's not clear in the documentation, but I'm pretty sure the OutputPrecision and Quality parameters map to fdwOutputPrecision and fdwQuality from CreateFont( ) in the Win32 API.

    If I'm remembering that correctly, then specifying ANTIALIASED_QUALITY or CLEARTYPE_QUALITY for the Quality param should do what you want. Although, I also remember reading somewhere that these flags are more "hints" than requirements - if the system can't satisfy your request you might still get a font - just a regular non-AA one.

    I think David was indicating that an example of this should be somewhere in the Text3D sample, so running a search on D3DXCreateFont() might yield some more information.

    hth
    Jack



  • recordus

    Hello,
          First, Thanks for replying. Secondly, I already know this sample. But I don't see that it provides me antialiased text.
    Thanks,
    Mustafa ELBanna

  • Cyb3rGlitch

    The "Text 3D" sample in the DirectX SDK should get you pointed in the right direction.

  • Game Squirrel

    Hello,
          Thanks for replying, It really doesn't change as I user True Type fonts. I think I'll make it a big map hold all the needed characters and the same map blurred. And I draw the character I want by drawing a polygon with a suitable size with texture coordinates applies to the character I want. Is this a good solution . I think this example at codeproject.com in VB making this.
    http://www.codeproject.com/vb/net/GraphicFonts.asp
    Thanks,
    Mustafa ELBanna


  • BAnVA

     MustafaELBanna wrote:

    Hello,
          Thanks for replying, It really doesn't change as I user True Type fonts. I think I'll make it a big map hold all the needed characters and the same map blurred. And I draw the character I want by drawing a polygon with a suitable size with texture coordinates applies to the character I want. Is this a good solution . I think this example at codeproject.com in VB making this.
    http://www.codeproject.com/vb/net/GraphicFonts.asp
    Thanks,
    Mustafa ELBanna


    For whatever reason that link isn't loading up at my end... so I haven't been able to check it out.

    I've written a fairly comprehensive font rasterizer for our graphics engine - a trivial fixed-width engine is simple (can be written inside of an hour probably), but for something approaching the power of D3DXFont's it'll take a *long* time. Especially if you want to maintain unicode/internationalization support.

    Another aspect is performance - string processing can be really painful. Much of the development time for my font rasterizer was spent on making it efficient when rendering (lots of caching of common strings, hash table lookups etc..)

    If you *really* need blurred/AA'd text, then you might want to employ D3DXFont's but render-to-texture and then post-process it for a 1px blur (or whatever). Although, be careful as a general blurring routine can make text unreadable - so you need to composite the original font over a blurred "base" layer to maintain readability.

    hth
    Jack



  • Solomonsd21

     MustafaELBanna wrote:
    Hello,
          I searched for a way to render an anti-aliased smooth ( and with a ClearType) text, But I didn't find .
    You probably don't want to use ClearType text in Direct3D application, even if it's possible.  ClearType makes assumptions about the exact position of the individual red, green and blue picture elements on the display screen.  If you rotate, scale and maybe even translate the text these assumptions will be broken and what gets displayed on screen could look pretty ugly.

    What I do in my own text rendering code is to render all the characters to a black and white one-bit DIB section and then supersample the bitmap down into a texture.  Rending to a one-bit bitmap ensures that Windows doesn't try use ClearType or anything when rendering the characters. 
     MustafaELBanna wrote:
    I want also to add a shadow to the font
    Just render your text twice, first draw the text in your shadow colour at an offset, then draw your normal text on top of the shadow.  For best results you should do this line by line, instead of character by character.

  • Rendering anti-aliased smooth text