bash - 如何使用 bash 从 ttf 字体获取字形宽度?

标签 bash glyph

width of a glyph

如何使用bash从字体文件中提取这个数字1139?

otfinfo 可以显示字形列表。

otfinfo --glyphs *.ttf

我想获取有关每个字形的信息,例如此页面:

http://bluejamesbond.github.io/CharacterMap/

但使用 bash。

我发现fontforge可以做到,

Get glyph widths by fontforge script

最佳答案

我认为您可以使用 ImageMagick 获得您想要的东西,它安装在大多数 Linux 发行版上,并且适用于 macOS 和 Windows。

基本上,您需要从命令行告诉 ImageMagick 创建一个包含单词“Test”的图像,并要求它在执行此操作时告诉您调试输出中的字体规范:

这里是 Anthony Thyssen 出色的“ImageMagick 使用页面” here 的示例。

convert -debug annotate  xc: -font "/Library/Fonts/Verdana Bold Italic.ttf" -annotate 0 "Test" null: 
2018-07-10T09:36:53+01:00 0:00.010 0.000u 7.0.7 Annotate convert[7893]: annotate.c/RenderFreetype/1545/Annotate
  Font /Library/Fonts/Verdana Bold Italic.ttf; font-encoding none; text-encoding none; pointsize 12
2018-07-10T09:36:53+01:00 0:00.010 0.000u 7.0.7 Annotate convert[7893]: annotate.c/GetTypeMetrics/931/Annotate
  Metrics: text: Test; width: 28; height: 15; ascent: 13; descent: -3; max advance: 21; bounds: 0.6875,-0.046875  5.96875,9; origin: 28,0; pixels per em: 12,12; underline position: -3.8125; underline thickness: 3.29688
2018-07-10T09:36:53+01:00 0:00.010 0.000u 7.0.7 Annotate convert[7893]: annotate.c/RenderFreetype/1545/Annotate
  Font /Library/Fonts/Verdana Bold Italic.ttf; font-encoding none; text-encoding none; pointsize 12

希望您能看到安东尼图表上详细说明的各种参数的所有值:

enter image description here

关于bash - 如何使用 bash 从 ttf 字体获取字形宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51239939/

相关文章:

qt - 为什么我的 QML CJK 文本呈现损坏的字形?

linux - 如何检查文件是否存在但在 shell 脚本的路径中间泛化?

bash - ssh 跳出 bash 中的 while 循环

bash - Unix cURL POST 到使用文件内容的特定变量

ios - 使用 attributedText 在自定义 UILabel 中定位字符坐标

r - 在文本中使用 adj 参数时, "large"标签的水平对齐会发生偏移

ios - 如何管理文本字形边界

pdf - PDF 中字形的精确边界框?

bash - 将数据格式化为表格格式

bash - 通过 “docker exec”执行bash脚本时,Docker在主机上查找脚本,但不在容器中查找脚本