latin: generic unicode display option of bar codes
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 11 Apr 2017 20:19:38 +0000 (22:19 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 22 May 2017 15:55:29 +0000 (17:55 +0200)
writing-latn.inc.pl

index 3aab17a9630c0930d0029b572c32ea39dd6f6af8..c026c0fcd0227dcb77b278a05e3b820099ad6f67 100644 (file)
@@ -1,6 +1,6 @@
 use 5.014;
 use utf8;
-use List::Util qw( pairs sum );
+use List::Util qw( pairs pairmap sum );
 
 my %C = qw(red #EC1C24  blue #3953A3  yellow #F9EC31  black #231F20);
 my $U = 0;  # optional unicode alternatives
@@ -15,7 +15,13 @@ sub disptap {
 }
 
 sub dispbar {
-       my @cols = split //, shift;  # bar and space widths
+       my $code = shift;
+
+       return join '', pairmap {
+               ($a =~ tr/123/❘❙❚/r) . ($b =~ tr/321/  /dr)
+       } split //, $code if $U;
+
+       my @cols = split //, $code;  # bar and space widths
        my $width = sum(@cols);
        return sprintf(
                '<svg width="%d" height="%d" viewBox="-.5 0 %d %d"><path d="%s"/></svg>',