1个不稳定版本
0.1.0 | 2024年7月26日 |
---|
#580 在 解析实现
118 每月下载量
41KB
829 行
这是一个跨平台程序,可以解析字体文件并打印出如度量、字体样式等信息。它可以找到系统中安装的字体或指向特定的字体文件。
支持的字体格式
- OpenType
- TrueType
支持的平台
- 类Unix(Fontconfig)
- Windows(DirectWrite;未测试)
- MacOS(Core Text;未测试)
使用方法
请参阅 $ font-info --help
以获取CLI使用文档。例如,要查找系统中“Liberation Sans”字体家族的所有字体并打印它们的度量,请运行
$ font-info --family-name "Liberation Sans"
-[ FONT 1 ]-------------------------------------------------
Source: /path/to/share/fonts/truetype/LiberationSans-Bold.ttf
Font index in source: 0
Weight: 700
Style: normal
Stretch: 1.00
Glyph count: 2620
Units per em: 2048
Average advance: 1248
Ascent: 1854
Descent: 434
Line height: 2288
Leading: 67
Capital height: 1409
"x" height: 1082
Stroke thickness: 215
Underline offset: -2
Strikeout offset: 530
-[ FONT 2 ]-------------------------------------------------
... etc
默认情况下,font-info生成人类可读的输出。要生成机器可读的JSON输出,请运行
$ font-info --family-name "Liberation Sans" --format json
您可以使用 --print-features
和 --print-writing-systems
标志来打印字体功能和支持的书写系统。
安装
使用Cargo安装
$ cargo install font-info
$ font-info --family-name "Liberation Sans"
使用Nix flakes运行
# Run ls
$ nix run github:tomcur/font-info -- --family-name "Liberation Sans"
依赖项
fontconfig
在类Unix系统中,此程序依赖于fontconfig(并在构建时使用pkg-config查找fontconfig)。例如,对于Debian或Ubuntu
$ sudo apt install pkg-config libfontconfig-dev
依赖项
~7–13MB
~160K SLoC