【问题标题】:How to get a glyph width from a ttf font using bash?如何使用 bash 从 ttf 字体获取字形宽度?
【发布时间】:2018-07-10 16:42:03
【问题描述】:

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

otfinfo 可以显示字形列表。

otfinfo --glyphs *.ttf

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

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

但是使用 bash。

我发现fontforge可以做到,

Get glyph widths by fontforge script

【问题讨论】:

  • 您尝试了哪些方法,又是如何失败的?请edit 你的问题包括otfinfo 工具的samble 输出和你到目前为止的代码。

标签: bash glyph


【解决方案1】:

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

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

所以,这里有一个来自 Anthony Thyssen 优秀的“ImageMagick Usage Pages”的例子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

希望您能在 Anthony 的图表中详细查看各种参数的所有值:

【讨论】:

    猜你喜欢
    • 2013-08-22
    • 2017-11-09
    • 2012-09-17
    • 2014-06-04
    • 2017-03-15
    • 2016-01-20
    • 2011-01-29
    • 2014-08-25
    • 2015-12-14
    相关资源
    最近更新 更多