在这里下载最新版本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; }