I am trying to extract kerning information out of some .ttf fonts with freetype 2.6 library.
This is how I get kerning informations (looping 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 the program with some different fonts: "Times new roman.ttf", "Tymes.ttf", "minion.otf". For Times new Roman font only, the kerning information are correctly extracted, and I checked that by logging the info.
The problem is that I don't understand why the 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 info are present for pairs "VA" and "To", and they are there! So they must be stored in the .ttf. Nevertheless, with the code above the kerning is always 0 for "VA" or "To", or FT_HAS_KERNING returns false.
Is there any freetype option or setting that I am missing here? Any kind of enlightenment is appreciated..
EDIT: I am setting the face size with
FT_Set_Pixel_Sizes( face->getFace(), 0, size);
kern
kerning (aka. "ye olde style"), or using a modern OpenTypeGPOS
table? "FreeType only supports kerning via the (rather simple) ‘kern’ table." (freetype.org/freetype2/docs/glyphs/glyphs-4.html) – Letishaletitiakern
table, onlyGPOS
. So you need a true OpenType enabled glyph renderer. (Unrelated: the glyphs for¼½¾
are really a mess...) – Letishaletitia