一 下载编译freetype库


1 下载

地址:http://www.freetype.org/
得到压缩文件:freetype-2.5.3.tar.gz


2 解压:

直接解压,得到文件夹freetype-2.5.3


3 编译:

用vs2010打开:(路径)\freetype-2.5.3\builds\windows\vc2010\freetype.sln




二 将freetype库加入到project

1 加入包括文件夹

依次点击:Project->properties->VC++directories->Include Directories
加入:(路径)\freetype-2.5.3\include


2 加入库文件夹

依次点击:Project->properties->VC++directories->Library Directories
加入:(路径)\freetype-2.5.3\objs\win32\vc2010


3 加入附加依赖项

依次点击:Project->properties->Linker->Input->Additional Dependencies
加入:(路径)\freetype253.lib;freetype253_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;
}




能编译执行,就一切ok了