#! /usr/bin/perl # Dump a font table structure use strict; use Font::TTF::Font; use Font::TTF::Scripts::AP; use Font::TTF::Dumper; use Pod::Usage; use Getopt::Std; our ($opt_a, $opt_t); getopts('a:t:'); unless (defined $ARGV[0]) { pod2usage( -verbose => 2, -noperldoc => 1); exit; } my ($f, $ap); if ($opt_a) { $ap = Font::TTF::Scripts::AP->read_font($ARGV[0], $opt_a) || die "Can't read font '$ARGV[0]': $!\n"; $f = $ap->{'font'}; } else { $f = Font::TTF::Font->open($ARGV[0]) || die "Can't open font file '$ARGV[0]': $!\n"; } my @tags; if ($opt_t) { @tags = split(/\s*[,\s]\s*/, $opt_t); } else { @tags = sort keys %{$f}; push @tags, 'AP' if $opt_a; } foreach (@tags) { next unless $_; if (length($_) == 4 and exists $f->{$_}) { $f->{$_}->read; print Font::TTF::Dumper::ttfdump(\$f->{$_}, $_); } elsif ($_ eq 'AP') { print Font::TTF::Dumper::ttfdump($ap, "AP"); } else { warn "Font doesn't contain a table with tag '$_'\n"; } } =head1 TITLE dumpfont - dump table structures from L =head1 SYNOPSIS dumpfont [-t taglist] [-a attach.xml] font.ttf Opens the fontfile with Font::TTF::Font->open or, if -a specified, Font::TTF::Scripts::AP->read_font, and then uses L to pretty-print the resultant data structures for one or more font tables to STDOUT. C is a comma-or space-separated list of tags specifying which tables to dump. If -a is supplied then C may contain 'AP' to request dump of the attachment point structure. If -t not provided, dumps all tables. By design, dumpfont silently ignores any ' PARENT' or ' CACHE' elements, as well as any element whose value is a Font::TTF::Font object, in any of the data structures. =cut