#!/usr/bin/env perl
# $Id: disp_hmtx,v 1.4 2003/08/05 16:26:37 s42335 Exp $
#
# 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 *
#

$p=$0; $p=~s:[^/]+$::; push(@INC,$p);
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();
