blob: b352d500b8be6d2ae5b73747cd11705209499afb [file] [log] [blame]
Raph Leviendcecdd82012-03-23 11:21:16 -07001# Copyright (c) 2012 Google Inc. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5# This is a simple utility for dumping out the header of a compressed file, and
6# is suitable for doing spot checks of compressed. files. However, this only
7# implements the "long" form of the table directory.
8
9import struct
10import sys
11
12def dump_woff2_header(header):
13 header_values = struct.unpack('>IIIHHIHHIIIII', header[:44])
14 for i, key in enumerate([
15 'signature',
16 'flavor',
17 'length',
18 'numTables',
19 'reserved',
20 'totalSfntSize',
21 'majorVersion',
22 'minorVersion',
23 'metaOffset',
24 'metaOrigLength',
25 'privOffset',
26 'privLength']):
27 print key, header_values[i]
28 numTables = header_values[3]
29 for i in range(numTables):
30 entry = struct.unpack('>IIIII', header[44+20*i:44+20*(i+1)])
31 print '%08x %d %d %d %d' % entry
32
33def main():
34 header = file(sys.argv[1]).read()
35 dump_woff2_header(header)
36
37main()
38