Font rendering with Freetype - Quality problems

Started by
1 comment, last by Plerion 10 years, 11 months ago
Hello

To render text im using freetype and a i create display lists that will be rendered. Now my problem is that on NVIDIA cards my text sometimes looks very bad (on ATI this problem does not occur). I have made an image showing the problem:
5198854aa3731_FontRender.jpg

The problem occurs if i render my text at a position that is not an integral number but of the form XXX.5f. If i change my code for example from
spriteFont->render(L"Loading...", (width - textWidth) * 0.5f, (height - textHeight) * 0.5f);

to

spriteFont->render(L"Loading...", (int32)((width - textWidth) * 0.5f), (int32)((height - textHeight) * 0.5f));

its fine no matter what the actual values are.

Is that a known effect?

Greetings
Plerion
Advertisement

Yes, this makes sense to me. When dealing with any pixel-perfect rendering, you should always represent your positions and sizes as integers. When you specify a 0.5f, the GPU will ultimately have to choose which pixel it gets mapped to (this is actually done based on your projection matrix). I'm not sure why it's different on NVIDIA vs ATI, but it's probably due to floating point math differences.

For pixel perfect rendering I would use an orthographic projection that maps directly to your screen resolution. Also make sure the viewport (glViewport() if you're using OpenGL) is also set to your screen resolution. Don't rely on the default viewport that is set for you when you bind the OpenGL context.

I've recently implemented font rendering using freetype and have had results almost exactly to what you have shown in your image.

Hey

Yes, im using an orthogonal matrix and a viewport according to the window size. About the difference on the cards ive realized that my ATI card runs on double precision while the NVIDIA is not.

So ill just stick to the integral values, now that i know it its ok :D

Greetings

Plerion

This topic is closed to new replies.

Advertisement