Make sure you call FT_Done_FreeType(lib_); after you close your program or stop using freetype. If this is not the case, then make sure you are using latest freetype version. I have almost the same loop and it works just fine on Windows 8 x64. Here's my code:
for (UINT32 i = 0; i < text.length(); i++) {
err_ = FT_Load_Char(face_, text[i], FT_LOAD_RENDER);
if (err_) {
LOGW("Unable to select, load and render character."
" Error code: %d", err_);
continue;
}
FT_Bitmap bitmap = glyphSlot->bitmap;
FT_UInt glyphIndex = FT_Get_Char_Index(face_, text[i]);
err_ = FT_Get_Kerning(face_, previous, glyphIndex,
FT_KERNING_DEFAULT, &delta);
if (err_) {
LOGW("Unable to get kerning for character."
" Error code: %d", err_);
continue;
}
Glyph tmp;
tmp.kerningOffset = delta.x >> 6;
tmp.buffer = new UINT8[bitmap.rows * bitmap.width];
memcpy(tmp.buffer, bitmap.buffer, bitmap.rows * bitmap.width);
tmp.height = bitmap.rows;
tmp.width = bitmap.width;
tmp.offsetLeft = glyphSlot->bitmap_left;
if (tmp.offsetLeft < 0) {
tmp.offsetLeft = 0;
}
tmp.offsetTop = glyphSlot->bitmap_top;
tmp.advanceX = glyphSlot->advance.x >> 6;
tmp.advanceY = glyphSlot->advance.y >> 6;
glyphs.push_back(tmp);
previous = glyphIndex;
width += tmp.advanceX + tmp.kerningOffset;
}
Also don't forget to delete symbol buffers if you allocate them separately:
for (SIZE i = 0; i < glyphs.size(); i++) {
Glyph g = glyphs[i];
delete [] g.buffer;
}