font: mark 16th column
[sheet.git] / font.plp
index 886792114ba97f74b23ad6c146e0e729ca22ccff..75f0198496877cd6ef495c59e9002f2b3f006789 100644 (file)
--- a/font.plp
+++ b/font.plp
@@ -18,7 +18,8 @@ if (my $font = $ENV{PATH_INFO} =~ s{^/}{}r) {
 
        require Unicode::UCD;
 
-       my $size = 0x200;
+       my $pagerows = 0x200;
+       my $pagecols = 32;
        my $offset = eval {
                local $_ = $get{q} || 0;
                return $_ if /\A\d+\z/;  # numeric
@@ -52,28 +53,44 @@ if (my $font = $ENV{PATH_INFO} =~ s{^/}{}r) {
        say <<"EOT";
 
 <style>
-       .glyphs tbody th { text-align: right }
+       .glyphs tbody th[!colspan] { text-align: right }
        .glyphs tbody td { font-family: "$fontmeta->{name}" }
+       .glyphs tbody td:nth-child(18) { border-left-width: 2px }
 </style>
 EOT
        say '<table class="glyphs big">';
+
        say "<caption>$_</caption>" for join(' ', grep {$_}
-               $offset > $size && sprintf('<a rel="start" href="?q=%d">◄</a>', 0),
+               $offset > $pagerows && 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,
+                       $offset - $pagerows,
                ),
-               sprintf('U+%04X', $offset), #TODO: block name
-               $offset + $size < 0x11_0000 && sprintf(
+               sprintf('U+%04X', $offset),
+               Unicode::UCD::charblock($offset),
+               $offset + $pagerows < 0x11_0000 && sprintf(
                        '<a rel="next" href="?q=%d" title="U+%1$04X">▻</a>',
-                       $offset + $size,
+                       $offset + $pagerows,
                ),
        );
-       for my $cp ($offset .. $offset+$size-1) {
+
+       for my $cp ($offset .. $offset+$pagerows-1) {
+               state $colpos;
+               my $block = Unicode::UCD::charblock($cp);
+               if ($block ne (state $sameblock = $block) and $block ne 'No_Block') {
+                       print '<tbody>';
+                       printf '<tr><th colspan=%d>%s', $pagecols+1, $block
+                               unless $block eq 'No_Block';
+                       say '';
+                       $sameblock = $block;
+                       $colpos = 0;
+               }
+
+               say sprintf '<tr><th>%X', $cp if $colpos++ % $pagecols == 0;
+
                my $info = $glyphs->glyph_info($cp);
                my ($class, $name, $mnem, $html, $string) = @{$info};
                my $np = $class =~ /\bC\S\b/;  # noprint if control or invalid
-               say sprintf '<tr><th>%X', $cp if $cp % 32 == 0;
                say sprintf '<td class="%s" title="U+%04X%s">%s',
                        !$class ? ('l0', $cp, '', '') :
                        $cover{$cp} ? $np ? 'l2' : 'l5' : $np ? 'Xi' : 'l1',