0
\$\begingroup\$

I'm able to render large text with FreeType just fine:

Large text

But when I want to render small text (and the only parameter that changes is the font size), the quality is much poorer:

Small text

As you can see, all the characters are very faint, although the 'o' and the 'w' look a bit better than the others.

I've Googled around for similar topics, and many people mention hinting as a potential source of problems. Right now I'm calling FT_Load_Glyph() with the FT_LOAD_DEFAULT flag, although I've tried pretty much every flag listed at http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_LOAD_XXX and none of them have produced adequate results.

Has anyone had a similar problem and determined how to fix it? I really need to render clearly-readable text at a small size, but I've heard that FreeType runs into problems here because certain hinting algorithms are patented, so should I look into an alternative text-drawing library and/or an alternative font? I'm not completely attached to this particular font (it's Liberation Sans TTF), so if there was another font I could use that would look better, that would be fine too.

\$\endgroup\$
3
  • \$\begingroup\$ If what @msell said is not an option, you could also use Valve's distance field method to render very sharp text at any size. \$\endgroup\$
    – akaltar
    Jun 27 '15 at 8:05
  • \$\begingroup\$ @akaltar Valve's distance field method doesn't render small text well. The big benefit of distance fields is that they make shapes in a texture remain smooth even when drawn much bigger on screen than the texture from which it's drawing. \$\endgroup\$ Jun 28 '15 at 0:18
  • \$\begingroup\$ @TrevorPowell But you could use hardware antialiasing or supersampling to get high quality text if you've got the performance to do it. \$\endgroup\$
    – akaltar
    Jun 28 '15 at 10:29
1
\$\begingroup\$

The problem is that your rendering is not pixel aligned. The same problem is visible with the bigger text as well. When zooming in, you can clearly see blurred edges everywhere. Interestingly this only happens in horizontal direction, not vertical. Without any code it's impossible to tell where the problem is, but first thing to do is make sure your horizontal alignment matches the vertical one. The problem could be e.g. in texture coordinates, vertex coordinates, projection or modelview matrix. As an easy fix you can also disable bilinear filtering.

What you have heard about FreeType's hinting is subtle compared to your problem and you will probably not see any difference without close examination compared to the patented method. Besides the patent has expired years ago and recent versions of FreeType has the better algorithm enabled by default.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.