在這裏下載最新版本http://download.savannah.gnu.org/releases/freetype/,我下的是freerype2.4.6
然後需要編譯,在 盤符:\freetype-2.4.6\builds\win32\vc2010 打開sln文件進行build,debug,release都build一下。
輸出的結果在 盤符:\freetype-2.4.6\objs\win32\vc2010 下
這裏如果運行,可能出現unable to start program的錯誤提示,不用管它,我們需要的文件生成了就行了。
VS2010的directory換地方了,
於是在Project----properties----VC++directories----Include Directories裏面添加 盤符:\freetype-2.4.6\include
在Library Directories裏添加 盤符:\freetype-2.4.6\objs\win32\vc2010
在Project----properties----Linker-----Input-----Additional Dependencies中添加 freetype246.lib;freetype246_D.lib
配置到此結束。
試試編譯一下以下代碼
#include <ft2build.h>
#include FT_FREETYPE_H
#include <iostream>
using namespace std;
int main()
{
FT_Library library;
FT_Init_FreeType(&library);
FT_Face face;
FT_New_Face(library, "msyh.ttf", 0, &face);
cout<<"num_glyphs:"<<face->num_glyphs<<endl;
cout<<"num_faces:"<<face->num_faces<<endl;
system("Pause");
return 0;
}
通過運行那麼就成功了。