font: do not align columns to a power of 32
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 6 Mar 2015 08:46:41 +0000 (09:46 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 9 Jun 2015 03:43:43 +0000 (05:43 +0200)
Alphabets do not specifically align this way as previously thought.

font.plp

index 8c9b098..a039905 100644 (file)
--- a/font.plp
+++ b/font.plp
@@ -74,22 +74,18 @@ EOT
        );
 
        for my $cp ($offset .. $offset+$pagerows-1) {
-               state $sameblock;
+               state $colpos;
                my $block = Unicode::UCD::charblock($cp);
-
-               if ($sameblock and $sameblock ne $block and $block ne 'No_Block') {
-                       say sprintf '<tbody><tr><th colspan=%d>%s', $pagecols+1, $block;
-                       undef $sameblock;
-               }
-
-               if (not $sameblock) {
+               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;
-                       if (my $gap = $cp % $pagecols) {
-                               say sprintf '<tr><th>%X<th colspan=%d>', $cp, $gap;
-                       }
+                       $colpos = 0;
                }
 
-               say sprintf '<tr><th>%X', $cp if $cp % $pagecols == 0;
+               say sprintf '<tr><th>%X', $cp if $colpos++ % $pagecols == 0;
 
                my $info = $glyphs->glyph_info($cp);
                my ($class, $name, $mnem, $html, $string) = @{$info};