FT_Library library;
if (FT_Init_FreeType(&library) != FT_Err_Ok) throw runtime_error("Failed to load freetype library");
FT_Face face;
if (FT_New_Memory_Face(library, fontData, fontDataSize, faceIndex, &face) != FT_Err_Ok) throw runtime_error("Failed to load face from font file");
FT_Set_Pixel_Sizes(face, 40, 20);
int glyphIndex = FT_Get_Char_Index(face, 65); // 65 is 'A'
if (glyphIndex == 0) throw runtime_error("Character doesn't exist in font");
FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT);
if (face->glyph->format != FT_GLYPH_FORMAT_BITMAP)
FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
FT_Bitmap bitmap = face->glyph->bitmap;
cout<<bitmap.rows<<' '<<bitmap.width<<endl;