freetype安装使用

1window VS搜索安装

 


编译移动IOS的2.7.1版本;源码从github下载; 

output_dir="${HOME}/Desktop/freetype"
min_iphoneos="7.0"
AR_POS=“/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar“
CC_POS=“/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang”  
export CC=$CC_POS  
ARCH=“arm64“  #在iPhone下使用静态库时,指定指令集ARM64,IPAD armv7.
export CFLAGS=“-arch $ARCH -pipe -mdynamic-no-pic -Wno-trigraphs -fpascal-strings -O2 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=$min_iphoneos -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk“ #指定编译选项,SDK位置
export AR="${AR_POS}"
export LDFLAGS=“-arch $ARCH -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -miphoneos-version-min=$min_iphoneos“#指定链接选项
./configure --host=“aarch64-apple-darwin” --enable-static=yes --enable-shared=no #生成静态链接库,编译出来的库文件执行的主机类型
make clean
make
mkdir -p $output_dir && cp objs/.libs/libfreetype.a "$output_dir/libfreetype-${ARCH}.a"

2.7.1编译的时候Freetype不支持bitcode属性;

使用:在配置文件info plist 上添加Fonts Provided by application ,在里边添加字体库支持

 编译使用的时候需要加上一些附加依赖库:libbz2.tbd,libz.tbd

写字需要使用的函数:

FT_init_freetype,创建,装载渲染模块,字体驱动模块,助手模块等
通过流FT_STREAM的形式读取字体文件
FT_new_face则会根据参数2的文件路径,创建文件流对象

FT_Set_Pixel_Sizes( face, 0,16 ); 设置字体像素大小16*16(以像素的形式设置字符大小)

FT_Set_Char_Size(   face    , 0    ,  16*64,    300, 300 );   在300*300dpi分辨率的设备上将字符大小设置成16*16pt(以点的形式设置字符的大小)

FT_BITMAP结构体内的 buffer存放字体的点阵,rows ,width存放点阵的宽,高.
逐行输出即可得到字体的点阵数据(8位抗锯齿模式FT_RENDER_MODE_NORMAL渲染点阵,点的数值0-255)
FT_SET_Transform 形变:仿射变换

字体排版参考: http://blog.sina.com.cn/s/blog_5d8cc6410100s2v1.html

原文地址:https://www.cnblogs.com/8335IT/p/15772572.html