【centos7】freetype2.10.0在linux上安装和使用 | 您所在的位置:网站首页 › freetype-devel › 【centos7】freetype2.10.0在linux上安装和使用 |
1:下载和配置 yum install -y bzip2 wget http://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.bz2 tar -jxvf freetype-2.10.0.tar.bz2 cd freetype-2.10.0 ./configure --prefix=/usr/local/freetype make make install 2:下载测试用例 yum install git git clone git://git.sv.nongnu.org/freetype/freetype2-demos.git 下面是example.c样例。 /* example1.c *//* *//* This small program shows how to print a rotated string with the *//* FreeType 2 library. */#include #include #include #include #include FT_FREETYPE_H#define WIDTH 180#define HEIGHT 50/* origin is the upper left corner */unsigned char image[HEIGHT][WIDTH];/* Replace this function with something useful. */voiddraw_bitmap( FT_Bitmap* bitmap,FT_Int x,FT_Int y){FT_Int i, j, p, q;FT_Int x_max = x + bitmap->width;FT_Int y_max = y + bitmap->rows;for ( i = x, p = 0; i width + p]; } }}voidshow_image( void ){int i, j;for ( i = 0; i bitmap_top );/* increment pen position */pen.x += slot->advance.x;pen.y += slot->advance.y; }show_image();FT_Done_Face ( face );FT_Done_FreeType( library );return 0;}/* EOF */
如果需要支持中文输出,应用下面的文件 /* example2.c *//* *//* This small program shows how to print a rotated string with the *//* FreeType 2 library. */#include #include #include #include #include #include FT_FREETYPE_H#define WIDTH 180#define HEIGHT 50/* origin is the upper left corner */unsigned char image[HEIGHT][WIDTH];/* Replace this function with something useful. */voiddraw_bitmap( FT_Bitmap* bitmap,FT_Int x,FT_Int y){FT_Int i, j, p, q;FT_Int x_max = x + bitmap->width;FT_Int y_max = y + bitmap->rows;for ( i = x, p = 0; i width + p]; } }}voidshow_image( void ){int i, j;for ( i = 0; i bitmap_top );/* increment pen position */pen.x += slot->advance.x;pen.y += slot->advance.y; }show_image();FT_Done_Face ( face );FT_Done_FreeType( library );return 0;}/* EOF */
将测试用例文件放在路径 /usr/local/freetype/lib/ 这个时候这个路径包含libfreetype.so等文件。 export LD_LIBRARY_PATH=/usr/local/freetype/lib/:$LD_LIBRARY_PATH cp example.c /usr/local/freetype/lib/example.c 这个路径同时放置两个字体文件进来,Public_V3.1.ttf和simsun.ttc 3:测试用例的编译和运行gcc -o example example.c -I /usr/local/freetype/include/freetype2/ -lfreetype -lm ./example simsun.ttc test
|
CopyRight 2018-2019 实验室设备网 版权所有 |