This is my first time that I use freetype library and I think I've got some problems. Right now, I draw the bitmap generated by freetype, but the generated image is really low quality. I've been reading about hinting and anti-aliasing, but the thing is none of them helped me and the problem is still here.

Take a look at my picture:

The rendered texture buffered with freetype bitmap

You can actually see what I mean.

I have applied a vertical hinting before rendering in my font class:

float scale = 100.0f;
FT_Matrix transform = 
    (int)((1.0 / scale) * 0x10000L),
    (int)((0.0) * 0x10000L),
    (int)((0.0) * 0x10000L),
    (int)((1.0) * 0x10000L)

FT_Set_Char_Size(this->mFace, 0, (int)(this->mSize * 64), (FT_UInt)(72 * scale), 72);
FT_Set_Transform(this->mFace, &transform, NULL);

I'm loading the character with:

FT_Load_Char(this->mpFont->Face(), this->mText[i], FT_LOAD_RENDER);

which is supposed to make the generated bitmap anti-aliased immediately as documentation has stated.

The part which I translate the buffer is here:

    BYTE intensity = bitmap->buffer[q * bitmap->pitch + p];
    D3DXCOLOR pixel(this->mColor.r * intensity, 
    this->mColor.g * intensity, 
    this->mColor.b * intensity, 
    this->mColor.a * intensity);

    this->mpTexture->SetPixel(i, j, pixel);

My texture format is A8R8G8B8 and I don't think I have anything wrong with my texture rendering part. The only thing that I'm not sure this is related to is the resolution. Currently I'm using the window size (640x480) which turns to lower resolution for device because of borders. By the way, this is a regular Tahoma font that I've used.


1 Answer 1


Your image suggests you're getting the Alpha wrong. Even if you do antialias, but then treat all non-transparent values as fully opaque, you'd get that.

You don't show the Render call, are you using FT_RENDER_MODE_DEFAULT?

  • \$\begingroup\$ Well there is no FT_RENDER_MODE_DEFAULT. The version I use is 2.3.5 and I think you're mentioning the previous versions. FT_Load_Char will do the render and eliminates the use of FT_Render_Glyph. I'll try to modify my color properties, I think I'm painting transparent pixels opaque as well. \$\endgroup\$
    – MahanGM
    Feb 12, 2014 at 12:29
  • \$\begingroup\$ I tried to change alpha value of pixel color, but there isn't any change. If I make it fully opaque, then there will be black background around the letters. I have to use intensity for transparency to get the image with right background and that doesn't change my words' shaped look, because in the dark background they still look the same. \$\endgroup\$
    – MahanGM
    Feb 12, 2014 at 12:54
  • \$\begingroup\$ I finally got over it :) The alpha value that I was setting as my font color was wrong. I was painting all pixels with full alpha. Thanks anyway. \$\endgroup\$
    – MahanGM
    Feb 12, 2014 at 15:14
  • \$\begingroup\$ I'm sorry to bother you again, but by any chance do you have any proper tutorial on drawing with freetype? \$\endgroup\$
    – MahanGM
    Feb 12, 2014 at 18:16
  • \$\begingroup\$ No, sorry; I sort of followed the documentation and it sort of worked. You may want to take a look at SDL_TTF, which wraps the FreeType library. \$\endgroup\$
    – ggambetta
    Feb 13, 2014 at 9:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .