11 our $VERSION = '1.01';
17 my ($ttfuri, $outfile) = @ARGV;
19 warn "usage error: input font not specified\n";
23 warn "font not found: $ttfuri\n";
27 for ($outfile || ()) {
28 open my $output, '>', $_ or die "Cannot write to $outfile: $!\n";
34 if ($ttfuri =~ /\.ttc\z/) {
35 require Font::TTF::Ttc;
36 my $collection = Font::TTF::Ttc->open($ttfuri) or die $!;
37 return $collection->{directs}->[0]; # first sub-font object
39 return Font::TTF::Font->open($ttfuri);
41 warn "Cannot open font file $ttfuri: ", $@ // $!;
45 my $ttfname = ($ttfuri =~ m{([^/.]+) (?:[.]ttf)? \z}msx)[0];
46 my $ttfmeta = $ttf->{name}->read;
48 source => abs_path($ttfuri) =~ m{(^/usr/.+ | [^/]+) \z}msx,
49 name => $ttfmeta->find_name(4) || $ttfname,
50 revision => sprintf('%g', $ttf->{head}->{fontRevision}),
51 version => $ttfmeta->find_name(5) =~ s/\Aversion //ri =~ s/\s+\z//r,
52 copyright=> scalar $ttfmeta->find_name(0),
53 license => $ttfmeta->find_name(14) || undef,
57 Time::Piece->new($_)->datetime;
59 } $ttf->{head}->getdate),
61 $meta{abbr} = lc join '', $meta{name} =~ s/ MS$//r =~ m{
62 (?!Sans) (?<! [0-9]) ([[:upper:]0-9])
65 say "# automatically generated by $0";
66 say '+', pp(\%meta), ',';
68 my $support = $ttf->{cmap}->find_ms->{val};
69 warn scalar keys %$support, " characters read from $ttfname\n"
71 say pp(sort { $a <=> $b } keys %$support);
78 mkttfinfo - Extract character coverage and metadata in TrueType font
82 mkttfinfo [-v] <font.ttf> [<output.inc.pl>]
86 Mischa POSLAWSKY <perl@shiar.org>
90 Licensed under the GNU Affero General Public License version 3.