Search code examples
c++freetype

Freetype correct positioning of letters and undestanding freetype FT_Face parameters


Im using Freetype for rastering text into a image, im getting the letters correctly but Im not taking into account if the letters should be putted lower than the "normal" level. Is there any parameter in the FT_Face of Freetype that tells me this.

Here is an example of the normal raster (correct) and mine. enter image description here


Solution

  • You're looking for the bitmap_top variable in the FT_GlyphSlotRec. It tells you how many pixels above the baseline the top of the glyph should be.

    There are more layout-related variables in FT_GlyphSlot so you might want to make sure you're not ignoring any that you should be paying attention to, such as the advance, which tells you how many 1/64ths of pixels you should move to the next glyph, and the bitmap_left, which (I think) tells you how many pixels to the right of the glyph position the bitmap should start.