When comparing fonts with .ttx files, convert the font to .ttx first
This bug was originally reported by Paul Wise (@pabs) in Debian bug #989626:
Package: diffoscope
Version: 177
Severity: wishlist
diffoscope currently prints a hex dump when comparing a TTF font with a
.ttx XML dump of a TTF font. If it used ttx (from fonttools) to convert
that TTF font to .ttx instead, then the comparison would become an XML
diff, which diffoscope treats as a text diff, which is better than hex.
$ git clone -q https://gitlab.gnome.org/GNOME/gtksourceview
=20
$ diffoscope gtksourceview/data/fonts/BuilderBlocks.tt{f,x}
--- gtksourceview/data/fonts/BuilderBlocks.ttf
+++ gtksourceview/data/fonts/BuilderBlocks.ttx
@@ -1,28 +1,259 @@
-00000000: 0001 0000 0008 0080 0003 0000 636d 6170 ............cmap
-00000010: 0021 0258 0000 0114 0000 004c 676c 7966 .!.X.......Lglyf
-00000020: 2644 7e48 0000 016c 0000 0030 6865 6164 &D~H...l...0head
-00000030: 0733 9950 0000 008c 0000 0036 6868 6561 .3.P.......6hhea
-00000040: 0c01 0402 0000 00c4 0000 0024 686d 7478 ...........$hmtx
-00000050: 0400 0000 0000 0108 0000 000a 6c6f 6361 ............loca
-00000060: 0024 000c 0000 0160 0000 000a 6d61 7870 .$.....`....maxp
-00000070: 0006 0005 0000 00e8 0000 0020 6e61 6d65 ........... name
...
+00000000: 3c3f 786d 6c20 7665 7273 696f 6e3d 2231 <?xml version=3D"1
+00000010: 2e30 2220 656e 636f 6469 6e67 3d22 7574 .0" encoding=3D"ut
+00000020: 662d 3822 3f3e 0a3c 7474 466f 6e74 2073 f-8"?>.<ttFont s
+00000030: 666e 7456 6572 7369 6f6e 3d22 5c78 3030 fntVersion=3D"\x00
+00000040: 5c78 3031 5c78 3030 5c78 3030 2220 7474 \x01\x00\x00" tt
+00000050: 4c69 6256 6572 7369 6f6e 3d22 322e 3422 LibVersion=3D"2.4"
+00000060: 3e0a 0a20 203c 476c 7970 684f 7264 6572 >.. <GlyphOrder
+00000070: 3e0a 2020 2020 3c21 2d2d 2054 6865 2027 >. <!-- The '
...
=20
$ dpkg -S `which ttx`
fonttools: /usr/bin/ttx
=20
$ ttx -o gtksourceview/data/fonts/BuilderBlocks.ttf.ttx gtksourceview/da=
ta/fonts/BuilderBlocks.ttf
Dumping "gtksourceview/data/fonts/BuilderBlocks.ttf" to "gtksourceview/d=
ata/fonts/BuilderBlocks.ttf.ttx"...
Dumping 'GlyphOrder' table...
Dumping 'head' table...
Dumping 'hhea' table...
Dumping 'maxp' table...
Dumping 'hmtx' table...
Dumping 'cmap' table...
Dumping 'loca' table...
Dumping 'glyf' table...
Dumping 'name' table...
=20
$ diffoscope gtksourceview/data/fonts/BuilderBlocks{,.ttf}.ttx
--- gtksourceview/data/fonts/BuilderBlocks.ttx
+++ gtksourceview/data/fonts/BuilderBlocks.ttf.ttx
@@ -1,65 +1,65 @@
-<?xml version=3D"1.0" encoding=3D"utf-8"?>
-<ttFont sfntVersion=3D"\x00\x01\x00\x00" ttLibVersion=3D"2.4">
+<?xml version=3D"1.0" encoding=3D"UTF-8"?>
+<ttFont sfntVersion=3D"\x00\x01\x00\x00" ttLibVersion=3D"4.19">
=20
<GlyphOrder>
<!-- The 'id' attribute is only for humans; it is ignored when pars=
ed. -->
<GlyphID id=3D"0" name=3D".notdef"/>
- <GlyphID id=3D"1" name=3D"block"/>
- <GlyphID id=3D"2" name=3D"empty"/>
- <GlyphID id=3D"3" name=3D"smallblock"/>
+ <GlyphID id=3D"1" name=3D"exclam"/>
+ <GlyphID id=3D"2" name=3D"uni0001"/>
+ <GlyphID id=3D"3" name=3D"a"/>
</GlyphOrder>
=20
<head>
<!-- Most of this table will be recalculated by the compiler -->
<tableVersion value=3D"1.0"/>
<fontRevision value=3D"1.0"/>
- <checkSumAdjustment value=3D"0x2a3f4cae"/>
+ <checkSumAdjustment value=3D"0x6b7bfd56"/>
<magicNumber value=3D"0x5f0f3cf5"/>
<flags value=3D"00000000 00000010"/>
<unitsPerEm value=3D"2048"/>
<created value=3D"Mon Oct 7 00:00:00 2013"/>
- <modified value=3D"Fri Jan 31 15:45:50 2014"/>
+ <modified value=3D"Tue Aug 1 21:25:46 2017"/>
<xMin value=3D"0"/>
<yMin value=3D"0"/>
- <xMax value=3D"0"/>
- <yMax value=3D"0"/>
+ <xMax value=3D"1024"/>
+ <yMax value=3D"2048"/>
<macStyle value=3D"00000000 00000000"/>
<lowestRecPPEM value=3D"1"/>
<fontDirectionHint value=3D"2"/>
<indexToLocFormat value=3D"0"/>
<glyphDataFormat value=3D"0"/>
</head>
...