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

写字需要使用的函数:

1
2
3
4
5
6
7
8
9
10
11
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

复制代码
armv7版本:

set -e

output_dir="${HOME}/Desktop/freetype.ios"
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="armv7"
export CFLAGS="-arch $ARCH -pipe -std=c99 -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" 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="arm-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"



arm64版本
#!/bin/bash

set -e

output_dir="${HOME}/Desktop/freetype.ios"
min_iphoneos="9.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"
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"
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"
复制代码

 

posted on   邗影  阅读(792)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
历史上的今天:
2020-01-06 关于openal报错找不到采集或播放设备
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示