font: navigation links to offset character table
[sheet.git] / font.plp
index e0a9663df6945bb46d2c6ec84d37a53b2ddbaece..2af6133da08094172b381f169d80ddebd726dbf7 100644 (file)
--- a/font.plp
+++ b/font.plp
@@ -17,6 +17,8 @@ if (my $font = $ENV{PATH_INFO} =~ s{^/}{}r) {
        $fontmeta or die "Unknown font $font\n";
 
        my $offset = $get{q} || 0;
+       $offset < 0 and $offset = 0;
+       my $size = 0x200;
 
        say "<h1>Font coverage</h1>";
        say "<h2>$_</h2>" for EscapeHTML($fontmeta->{name});
@@ -47,7 +49,19 @@ if (my $font = $ENV{PATH_INFO} =~ s{^/}{}r) {
 </style>
 EOT
        say '<table class="glyphs big">';
-       for my $cp ($offset .. $offset+0x1FF) {
+       say "<caption>$_</caption>" for join(' ', grep {$_}
+               $offset > $size && sprintf('<a rel="start" href="?q=%d">◄</a>', 0),
+               $offset > 0 && sprintf(
+                       '<a rel="prev" href="?q=%d" title="U+%1$04X">◅</a>',
+                       $offset - $size,
+               ),
+               sprintf('U+%04X', $offset), #TODO: block name
+               $offset + $size < 0x11_0000 && sprintf(
+                       '<a rel="next" href="?q=%d" title="U+%1$04X">▻</a>',
+                       $offset + $size,
+               ),
+       );
+       for my $cp ($offset .. $offset+$size-1) {
                my $info = $glyphs->glyph_info($cp);
                my ($class, $name, $mnem, $html, $string) = @{$info};
                my $np = $class =~ /\bC\S\b/;  # noprint if control or invalid