查找两个(可能是 OpenType)字体文件的差异

Finding the differences in two (probably OpenType) font files

我在两个文件中有相同的字体,都没有文件扩展名。

两个文件都以类型代码 OTTO 开头,因此字体必须是 OpenType.

当我添加文件扩展名 .otf 并在字体编辑器中打开文件时,它们看起来相同并且包含相同的字形。

但是当我diffVim中的文件时,文件的某些部分不同,但是由于代码对我来说是看不懂的,所以我无法理解这些部分的字体是什么方面的文件参考。

如何找出这两个字体文件之间的区别?

您应该找到工具 ttx [1].

这是一个命令行工具,用于将字体文件从 OpenType 格式转换为 XML 表示形式,然后再转换回来。

XML 表示在任何文本编辑器中都非常容易编辑(例如,对字体进行微小更改)。也应该很容易(滥用)将其用作可以进行比较的格式。

所以这些命令应该给你一个起点:

ttx -l otf1file
ttx -l otf2file

-l 选项尚未剖析(并转换为 XML)字体文件。相反,它会打印 table 的概述,如下所示:

 Listing table info for "/Library/Fonts/WeidemannStd-Medium.otf":
     tag     checksum   length   offset
     ----  ----------  -------  -------
     BASE  0x3f624fba       52    24836
     CFF   0xec0764e1    18801     2752
     DSIG  0xa4d90535     5180    24888
     GPOS  0xffb60926     1456    23380
     GSUB  0x6de87013      812    22568
     OS/2  0x7c681439       96      320
     cmap  0x79e54a16      932     1788
     head  0xd391fc8f       54      220
     hhea  0x06fd0364       36      276
     hmtx  0xf9581b97     1012    21556
     maxp  0x00fd5000        6      312
     name  0x987b2db3     1370      416
     post  0xffb80032       32     2720

既然您已经熟悉了 table 的一些细节,您可能只想看看这些 table 的不同之处。假设只有 cmapname tables:

ttx -o otf1-cmap+name-tables.ttx -t cmap -t name otf1file
ttx -o otf2-cmap+name-tables.ttx -t cmap -t name otf2file
vimdiff otf1-cmap+name-tables.ttx otf2-cmap+name-tables.ttx

如果 all tables 不同,您可以通过跳过 -t参数:

ttx -o otf1.ttx  otf1file
ttx -o otf2.ttx  otf2file
vimdiff otf1.ttx  otf2.ttx

更新: 另一个有用的工具(也来自 Adob​​e Type Tools 存储库)可能是 sfntdiff

但可能 ttxn 工具最适合您。这是它的自我描述:

"This tool is used to test if two fonts are functionally the same. It sorts and modifies the output from the ttx and tx tools to build a normalized text dump that eliminates differences due to issues such as OTL table record order, glyph order and subroutinzation differences. It writes one file for each table in the font. A good difference editor, such as BBEdit on the Mac, or UltraEdit on the PC, can then be used to compare the output files from two different fonts. It is particularly useful in comparing older and newer versions of the same font."


[1]TTX 最初由 Just van Rossum 于 1999 年开发,并作为开源项目维护在 SourceForge (sf.net/projects/fonttools/) 上。它写在Python:

  1. Git 存储库:github.com/adobe-type-tools/afdko.git(在 "afdko/FDK/Tools/${operatingsystem}/" 子目录中查找!)
  2. "Friendly" 原始 repo 的分支,由 Behdad Esfahbod 进行了大量修复、改进和补充:github.com/behdad/fonttools/