font: coverage data as cover array in primary hash
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 26 May 2022 21:02:23 +0000 (23:02 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 2 Jun 2022 21:57:11 +0000 (23:57 +0200)
Single object for json compatibility.

font.plp
tools/mkttfinfo

index cb6cd358d487369a79f2943f0a8cf6b50206aa08..f17eab569e16c522d717b46959000b4ce3ecee8f 100644 (file)
--- a/font.plp
+++ b/font.plp
@@ -14,7 +14,7 @@ Html({
 });
 
 if ($font) {
-       my ($fontmeta, @cover) = eval { Data("data/font/$font") }
+       my $fontmeta = eval { Data("data/font/$font") }
                or Abort("Unknown font $font", '404 font not found', ref $@ && $@->[1]);
 
        my $map = eval {
@@ -59,7 +59,7 @@ if ($font) {
        printf("<p>Version <strong%s>%s</strong> released %s contains %d glyphs.",
                !!$_->[2] && qq( title="revision $_->[2]"),
                $_->[1], $_->[0],
-               scalar @cover,
+               scalar @{ $fontmeta->{cover} },
        ) for [
                grep { $_ }
                ($fontmeta->{date} || '?') =~ s/T.*//r,
@@ -86,7 +86,7 @@ if ($font) {
        require Shiar_Sheet::FormatChar;
        my $glyphs = Shiar_Sheet::FormatChar->new;
 
-       my %cover = map { ($_ => 1) } @cover;  # lookup map
+       my %cover = map { ($_ => 1) } @{ $fontmeta->{cover} };  # lookup map
 
        say <<"EOT";
 
index 8cfe446a2b63e295bc5b714e170e894226d2561b..b14539a444f9ac750c93971885c7657d338d5f9f 100755 (executable)
@@ -7,7 +7,7 @@ use Font::TTF::Font;
 use Getopt::Long;
 use Cwd 'abs_path';
 
-our $VERSION = '1.01';
+our $VERSION = '1.02';
 
 GetOptions(\my %opt,
        'verbose|v!',
@@ -72,13 +72,13 @@ for ($outfile || ()) {
                undef
        ) for $meta{os} || ();
 
-       say "# automatically generated by $0";
-       say '+', pp(\%meta), ',';
-
        my $support = $ttf->{cmap}->find_ms->{val};
        warn scalar keys %$support, " characters read from $ttfuri\n"
                if $opt{verbose};
-       say pp(sort { $a <=> $b } keys %$support);
+       $meta{cover} = [sort { $a <=> $b } keys %$support];
+
+       say "# automatically generated by $0";
+       say '+', pp(\%meta);
 }
 
 __END__