9 my ($ttfuri, $outfile) = @ARGV;
10 $ttfuri or die "usage error\n";
12 for ($outfile || ()) {
13 !-e $_ or die "Output file $outfile already exists\n";
14 open my $output, '>', $_ or die "Cannot write to $outfile: $!\n";
19 'Times New Roman' => 'times',
20 'DejaVu Sans' => 'dv ss',
21 'DejaVu Serif' => 'dv serif',
23 'GNU Unifont' => 'guf',
24 'Droid Sans' => 'droid',
25 'Droid Serif' => 'droid serif',
29 my $ttf = Font::TTF::Font->open($ttfuri)
30 or die "Cannot open truetype in $ttfuri: $!";
32 my $ttfname = ($ttfuri =~ m{([^/.]+) (?:[.]ttf)? \z}msx)[0];
35 name => $ttf->{name}->read->find_name(4) || $ttfname,
36 version => $ttf->{head}->{fontRevision},
40 Time::Piece->new($_)->datetime;
42 } $ttf->{head}->getdate),
44 $meta{id} = $FONTID{ $meta{name} } // lc $ttfname;
47 my $support = $ttf->{cmap}->find_ms->{val};
48 warn scalar keys %$support, " characters read from $ttfname\n";
49 say pp(sort { $a <=> $b } keys %$support);
56 convert-ttf.pl - Writes unicode characters present in TrueType font
60 convert-ttf <font.ttf> [<output.inc.pl>]
64 Mischa POSLAWSKY <perl@shiar.org>
68 Licensed under the GNU Affero General Public License version 3.