OpenGL

Visual Studio: Setting FreeType Library

FunnyPR 2014. 5. 16. 12:09

■ Visual Studio: Setting FreeType Library


FreeType는 폰트처리용 오픈소스 라이브러리이며 GPL 라이센스를 따른다.


이 글에서는 Windows 운영체제에서 Visual Studio(C++/MFC)를 기준으로 어떻게 FreeType 라이브러리 개발환경을 구현해야 하는지 알아보자 


1. FreeType Library 다운로드

http://freetype.sourceforge.net/download.html#stable : FreeType 사이트 

http://sourceforge.net/projects/freetype/files/ : FreeType 파일 

sourceforge에서 FreeType 파일 받기 



파일 받은 후 경로 상관 없이 압축풀기 


2. FreeType Library 빌드

압축풀려진 폴더에서 해당 visual 버전별 폴더로 이동 하여 프로젝트 파일 열기 

......\ft253\freetype-2.5.3\builds\windows\vc2010


프로젝트 열면 솔루션 탐색기에서 다음과 같이 FreeType 소스코드와 헤더 파일을 확인할 수 있음


솔루션 빌드 하면 다음과 같이 freeType253_D.lib가 생성됨 욘속을 사용해야 함


생성된 lib 파일 확인: 다른 환경의 라이브러리를 만들기 위해서는 빌드시 플랫폼을 설정하면 됨

.......\ft253\freetype-2.5.3\objs\win32\vc2010



3. 새 프로젝트 생성 및 FreeType 헤더파일 추가

MFC-대화상자 기반 프로젝트 생성

생성된 프로젝트 폴더에 FreeType 헤더파일 폴더 복사 

Copy the include Folder of FreeType to User Project Folder

.......\ft253\freetype-2.5.3\include


생성된 프로젝트에 복사된 FreeType 헤더파일 폴더


4. 프로젝트 속성 설정 

프로젝트 속성-> 구성속성 -> C/C++  -> 추가 포함 디렉토리 -> 편집 -> Include 폴더 선택 


추가된 FreeType 헤더파일 확인 


라이브러리 추가 

프로젝트 속성-> 구성속성 -> 링커 -> 일반 -> 추가라이브러리 디렉토리 -> 이전 생성된 라이브러리 있는 폴더 선택 

.......\ft253\freetype-2.5.3\objs\win32\vc2010


추가 종속성 설정 

링커 -> 입력 -> 추가 종속성 -> freetype253_D.lib;


5. FreeType 초기화 및 프로젝트 빌드 

가. 헤더파일 선언

#include <ft2build.h>

#include FT_FREETYPE_H


나. 라이브러리 초기화 (OnInitDialog() 에서 확인)

FT_Library ft;


if (FT_Init_FreeType(&ft)) {

fprintf(stderr, "Could not init freetype library\n");

return 1;

}


다. 컴파일 및 확인 

흠 우선은 에러 없이 잘 컴파일 되었넹 what a wonderful work!!!!

씨익 ^____________________^


참고 사이트

   - http://mgun.tistory.com/115

   - http://blog.naver.com/PostView.nhn?blogId=pumpguy&logNo=30098170538

   - http://www.sccs.swarthmore.edu/users/03/sven/freetype_tut/