use Data::Dump 'pp';
use Font::TTF::Font;
+use Getopt::Long;
+
+our $VERSION = '1.00';
+
+GetOptions(my %opt,
+ 'verbose|v!',
+);
my ($ttfuri, $outfile) = @ARGV;
$ttfuri or die "usage error\n";
+my $fontinc = $ENV{FONTINC} // '~/.fonts,/usr/share/fonts/truetype/*';
+if (!-e $ttfuri) {
+ my $found = (grep {-e} glob "{$fontinc}/$ttfuri")[0] or do {
+ warn "font not found: $ttfuri\n";
+ exit 1;
+ };
+ $ttfuri = $found;
+}
+
for ($outfile || ()) {
open my $output, '>', $_ or die "Cannot write to $outfile: $!\n";
select $output;
} $ttf->{head}->getdate),
);
$meta{id} = $FONTID{ $meta{name} } // lc $ttfname;
- say pp(\%meta), ',';
+ say "# automatically generated by $0";
+ say '+', pp(\%meta), ',';
my $support = $ttf->{cmap}->find_ms->{val};
- warn scalar keys %$support, " characters read from $ttfname\n";
+ warn scalar keys %$support, " characters read from $ttfname\n"
+ if $opt{verbose};
say pp(sort { $a <=> $b } keys %$support);
}
=head1 SYNOPSIS
- mkttfinfo <font.ttf> [<output.inc.pl>]
+ mkttfinfo [-v] <font.ttf> [<output.inc.pl>]
=head1 AUTHOR