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";
33 my $ttf = Font::TTF::Font->open($ttfuri) or do {
34 warn "Cannot open truetype in $ttfuri: $!";
38 my $ttfname = ($ttfuri =~ m{([^/.]+) (?:[.]ttf)? \z}msx)[0];
39 my $ttfmeta = $ttf->{name}->read;
41 source => abs_path($ttfuri) =~ m{(^/usr/.+ | [^/]+) \z}msx,
42 name => $ttfmeta->find_name(4) || $ttfname,
43 revision => sprintf('%g', $ttf->{head}->{fontRevision}),
44 version => $ttfmeta->find_name(5) =~ s/\Aversion //ri =~ s/\s+\z//r,
45 copyright=> scalar $ttfmeta->find_name(0),
46 license => $ttfmeta->find_name(14) || undef,
50 Time::Piece->new($_)->datetime;
52 } $ttf->{head}->getdate),
54 $meta{abbr} = lc join '', $meta{name} =~ s/ MS$//r =~ m{
55 (?!Sans) (?<! [0-9]) ([[:upper:]0-9])
58 say "# automatically generated by $0";
59 say '+', pp(\%meta), ',';
61 my $support = $ttf->{cmap}->find_ms->{val};
62 warn scalar keys %$support, " characters read from $ttfname\n"
64 say pp(sort { $a <=> $b } keys %$support);
71 mkttfinfo - Extract character coverage and metadata in TrueType font
75 mkttfinfo [-v] <font.ttf> [<output.inc.pl>]
79 Mischa POSLAWSKY <perl@shiar.org>
83 Licensed under the GNU Affero General Public License version 3.