Directxtk SpriteFont blurry when not whole number

236 Views Asked by At

enter image description here

The text becomes blurry if I use a non whole number for the position of the string. Any ideas what is causing this and how to correct it?

this->pSpriteBatch->Begin();
this->pSpriteFont->DrawString(this->pSpriteBatch, szTempMessage, XMFLOAT2(x, y), color);
this->pSpriteBatch->End();

I'm calling it with only the position and color parameters.

1

There are 1 best solutions below

0
Chuck Walbourn On

SpriteBatch renders using CommonStates::LinearClamp by default, so it will be blurry if you rendering to a sub-pixel location. You can try using another filtering mode by overriding it with Begin:

// create an instance of CommonStates as pStates

pSpriteBatch->Begin(SpriteSortMode_Deferred,
    nullptr /*use default blend state */,
    pStates->AnisotropicClamp());
pSpriteFont->DrawString(...);
pSpriteBatch->End();

See if that improves your results.