I am trying to extract kerning information from some .ttf fonts with freetype 2.6 library.
This is how I get kerning information (by scrolling through characters):
if( FT_HAS_KERNING(face->getFace()) && previous ){ FT_Vector delta; FT_UInt glyph_index = FT_Get_Char_Index( face->getFace(), character ); FT_UInt prev_index = FT_Get_Char_Index( face->getFace(), previous ); FT_Get_Kerning( face->getFace(), prev_index, glyph_index, FT_KERNING_DEFAULT, &delta ); kerning = delta.x >> 6; }
I tried a program with several different fonts: "Times new roman.ttf", "Tymes.ttf", "minion.otf". For Times New Roman fonts only, kerning information is correctly extracted, and I checked this by registering the information.
The problem is that I donβt understand why kerning is always 0 (i.e. FT_HAS_KERNING returns false, and FT_GetKerning returns 0 anyway) for the other 2 fonts.
I checked with fontforge that kerning information is present for the "VA" and "To" pairs, and they are! Therefore, they must be stored in .ttf. However, with the code above, kerning is always 0 for "VA" or "To", or FT_HAS_KERNING returns false.
Is there any freetype parameter or parameter that I am missing here? Any enlightenment is welcome.
EDIT: I set face size using
FT_Set_Pixel_Sizes( face->getFace(), 0, size);
EDIT: Kerning for the font "tymes" in fontforge: 