#!/usr/bin/perl
#
# usage: disp_hdmx hdmx numGlyphs (DONT USE STDIN)
#
# display the content of hdmx (Horizontal Device MetriX) table.
#
# NOTE: output format is *NOT* compatible with my make_hdmx...
#
#	2002/2/5, by 1@2ch
#	* public domain *
#

require 'lib_util.pl';

sub usage() {
    print "usage: disp_hdmx hdmx maxp:numGlyphs\n";
    exit 1;
}

2 == @ARGV || usage();
($f, $numGlyphs) = @ARGV;
ropen($f);

$version = ruint16();
$numRecords = rsint16();
$sizerec = ruint32();
printf "version: 0x%04x\n", $version;
print "sizerec: $sizerec\n";

for(my $i = 0; $i < $numRecords; $i++) {
    rgoto($sizerec * $i + 2+2+4);
    print "ppem: ", ruint8(), "\n";
    print "maxwidth: ", ruint8(), "\n";
    for(my $n = 0; $n < $numGlyphs; $n++) {
	print "glyph $n: ", ruint8(), "\n";
    }
    print "\n";
}
rclose();
