7 use open OUT => ':utf8', ':std';
8 use List::Util 'reduce';
9 use File::Basename 'basename';
12 our $VERSION = '1.00';
15 my $incsuffix = '.inc.pl';
16 for my $fontfile (glob 'ttfsupport/*'.$incsuffix) {
17 my ($fontid) = basename($fontfile, $incsuffix);
18 my ($fontmeta, @fontrange) = do $fontfile or next;
20 -id => $fontmeta->{id} || $fontid,
21 -name => $fontmeta->{name},
22 map { (chr $_ => 1) } @fontrange
28 my $chartables = do 'unicode-table.inc.pl' or warn $@ || $!;
30 while (my ($tablegroup, $grouprow) = each %{$chartables}) {
31 while (my ($tablename, $chars) = each %{$grouprow}) {
32 next if $tablename =~ /^-/;
33 my $includerows; # ignore rows before body row
35 $includerows ||= m/^[.]/ or next;
37 next if $_ eq '>' or $_ eq '=';
39 push @{ $charlist{table}->{"$tablegroup/$tablename"} }, $_;
40 push @{ $charlist{table}->{$tablegroup} }, $_;
43 # if ($tablegroup eq 'ipa') {
44 # @chars = grep { !m/[a-zA-Z]/ } @chars;
49 use Unicode::UCD 'charinfo';
50 for my $code (0 .. 256**2) {
51 my $charinfo = charinfo($code) or next;
52 next if $charinfo->{category} =~ /^[MC]/; # ignore Marks and "other" Control chars
53 push @{ $charlist{$_}->{ $charinfo->{$_} } }, chr $code
54 for qw( script category block );
57 for (values %charlist) {
58 for my $chars (values %{$_}) {
60 my $fontcover = $font{$_};
61 ($_ => scalar grep { $fontcover->{$_} } @{$chars});
63 $row{-count} = scalar @{$chars};
66 my @query = map { ord } sort @{$chars};
73 last if $query[$j] != $v;
77 splice(@query, $i, $j - $i, "$query[$i]-$query[$j-1]");
81 return join '+', @query;
89 say '+'.pp(\%charlist);
95 mkfontinfo - Prepare font coverage of various character groups
99 mkfontinfo > unicode-cover.inc.pl
101 Test by finding the number of cyrillic characters in DejaVu Sans:
103 perl -E'$f = do "unicode-cover.inc.pl"; say $f->{Cyrillic}->{dvsans}'
107 Mischa POSLAWSKY <perl@shiar.org>
111 Licensed under the GNU Affero General Public License version 3.