#!/usr/bin/perl
#
# usage: disp_hmtx hmtx numberOfMetrics numGlyphs
#    or: disp_hmtx -  numberOfMetrics numGlyphs  (from stdin)
#
# display the content of hmtx/vmtx (Horizontal/Vertical MeTriX) table.
#
# NOTE: output format is *NOT* compatible with my make_hmtx...
#
#	2002/2/3, by 1@2ch
#	* public domain *
#

require 'lib_util.pl';

sub usage() {
    print "usage: disp_hmtx hmtx hhea:numberOfHMetrics maxp:numGlyphs\n";
    exit 1;
}

3 <= @ARGV || usage();
($f, $numofHMetrics, $numGlyphs) = @ARGV;
ropen($f);
print "hMatrics:\n";
for(my $i = 0; $i < $numofHMetrics; $i++) {
    my $advanceWidth = ruint16();
    my $leftSideBearing = rsint16();
    print "glyph $i: $advanceWidth, $leftSideBearing\n";
}

print "\nleftSideBearing:\n";
for(my $i = 0; $i < $numGlyphs-$numofHMetrics; $i++) {
    print "$i: ", rsint16(), "\n";
}
rclose();
