fontTools
$ fonttools 社区开源 低风险fontTools 是权威的 Python 字体工程工具包,可通过 fonttools、pyftsubset 与 ttx 检查、子集化、合并及 XML 导出 TrueType/OpenType 字体。Agent 可用 ttx -l 列出 SFNT 表目录、用 -t 选择性导出 XML,或在 CI 中安全子集化 Web 字体(--flavor=woff2)。
brew install fonttools 二进制字体表检查(ttx -l)与子集化(fonttools subset)直接在本地 .ttf/.otf/.woff2 文件上处理,无需 MCP。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
各子命令(subset、ttx、varLib、merge)均支持无头确定性执行,且 ttx 支持 -o - 标准输出,但检查输出为 XML 或纯文本表格而非 JSON。
ttx -landttx -t <table> -o -enable targeted read-only inspection- Outputs XML/plain tables rather than JSON
100% 离线本地字体处理;显式传入 --output-file / -o 时原字体文件保持不变。
- Non-destructive when explicit
--output-fileis passed
可通过 Homebrew、pip 与 uvx 在 macOS、Linux 与 Windows 安装(导出 woff2 需搭配 brotli)。
- Cross-platform
brew install fonttoolsandpip install fonttools
字体子集化、可变字体实例化与表结构调试的行业标准瑞士军刀。
- Covers
subset,ttx,varLib,feaLib, andmergein one suite
由字体工程社区积极维护的 MIT 开源项目(fonttools/fonttools)。
- Canonical
fonttools/fonttoolsupstream repository
Read the Docs 提供覆盖 subset、ttx、varLib 等 CLI 工具的完整参考文档。
- Official docs at fonttools.readthedocs.io
安全边界、鉴权与放权指南
无需凭据;仅操作本地字体二进制与 .ttx XML 文件。
100% 免费、离线且遵循 MIT 开源协议(使用 --flavor=woff2 需安装 brotli Python 包)。
# fontTools Agent Rules - Use `ttx -l <font>` or `ttx -t <tableTag> -o - <font>` for read-only inspection before dumping full `.ttx` files (which can be huge). - Always pass `--output-file=<path>` to `fonttools subset` / `pyftsubset` so source fonts are preserved.
Agent 高频安全命令配方
只读查询(安全推荐)
ttx -l font.ttf
打印 SFNT 表目录(cmap、glyf、GSUB 等),不修改或导出任何文件。
ttx -t name -o - font.ttf
仅将 name 表以 XML 形式导出到标准输出(-o -),实现安全只读检查。
受控写入与预演
fonttools subset font.ttf --unicodes=U+0020-007E --output-file=font.subset.ttf
仅保留请求的 Unicode 范围并输出紧凑的 font.subset.ttf 文件。
核心优势
- + 字体子集化(
pyftsubset)、可变字体实例化与ttxXML 检查的行业标准工具。 - +
ttx -l与ttx -t <table> -o -可避免无谓导出数 MB 的字形表。 - + 100% 离线运行且采用 MIT 开源协议。
注意事项与踩坑点
- ! 启用
--flavor=woff2需安装fonttools[woff](brotli)。 - ! 对大型 CJK 字体执行完整
ttx导出可能生成数十 MB 的 XML 文件。