font: save queried character numbers in include
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 9 Apr 2012 23:40:49 +0000 (01:40 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 10 Apr 2012 01:03:24 +0000 (03:03 +0200)
tools/mkfontinfo

index 0f0857d..a6dc15a 100755 (executable)
@@ -63,7 +63,25 @@ for my $chars (values %{$_}) {
                ($_ => scalar grep { $fontcover->{$_} } @{$chars});
        } keys %font;
        $row{-count} = scalar @{$chars};
-#      $row{-chars} = [ map { ord } sort @{$chars} ];
+
+       $row{-query} = eval {
+               my @query = map { ord } sort @{$chars};
+               my $i = 0;
+               while ($i < @query) {
+                       my $j = $i + 1;
+                       my $v = $query[$i];
+                       while ($j < @query) {
+                               $v++;
+                               last if $query[$j] != $v;
+                               $j++;
+                       }
+                       if ($j - $i > 2) {
+                               splice(@query, $i, $j - $i, "$query[$i]-$query[$j-1]");
+                       }
+                       $i++;
+               }
+               return join '+', @query;
+       };
 
        $chars = \%row;
 }