# 字体瘦身工具 **Repository Path**: a20070322/ttf_tool ## Basic Information - **Project Name**: 字体瘦身工具 - **Description**: 提取TTF字体,字体瘦身工具 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 9 - **Created**: 2022-03-17 - **Last Updated**: 2022-03-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 说明 游戏开发中经常会使用到TTF字体,尤其在有中文的情况下,一般的TTF字集大小都在好几兆,这对游戏来说会增加非常大的包体。所以我们需要尽可能的缩小字集的大小。 通常情况下,我们会用BMFont代替TTF字体,BMFont也有着很多的优势,但是缺点也很明显,每次修改都要美工的配合,而且不支持字号改变(不考虑缩放) ## 介绍 sfnttool 是谷歌开源项目 sfntly 内置的工具,他的作用是从一个字体文件中提取指定的文字,导出的字体中将只包含你需要的文字 ## 下载 http://download.csdn.net/detail/ldpjay/8822587 ## 运用 1. 确保电脑已安装了java环境,jdk版本在1.6以上 1. 使用命令行进入`sfnttool.jar` 所在的目录下 1. 输入以下命令 ```java java -jar sfnttool.jar -s '这是一段测试文字' before.ttf font.ttf ``` `-s` 后面跟的是你需要提取的文字 `beffore.ttf` 是转换前的ttf文件 `font.ttf` 是转换后的ttf文件 1.其他的一些用法 ```java java -jar sfnttool.jar -h subset [-?|-h|-help] [-b] [-s string] fontfile outfile prototype font subsetter -?,-help print this help information -s,-string string to subset -b,-bench benchmark (run 10000 iterations) -h,-hints strip hints -w,-woff output woff format -e,-eot output eot format -x,-mtx enable microtype express compression for eot format ```