latin: code 128 as svg images
[sheet.git] / writing-latn.inc.pl
index 83bdfcbc5380a59edeccb780fe2f38f4b8237f4e..7fabb6ed1520eb3407706358d894a5cca93565cb 100644 (file)
@@ -3,21 +3,21 @@ use utf8;
 sub disptap {
        return map {
                !m/\A(-?)(\d)(\d)/ ? $_ :
-               sprintf('<td%s>%s<br>%s',
-                       ' class=ex' x !!$1,
+               $1.sprintf('%s<br>%s',
                        '·' x $2, '·' x $3,
                );
        } @_;
 }
 
 my %C = qw(red #EC1C24  blue #3953A3  yellow #F9EC31  black #231F20);
+my $U = 0;  # optional unicode alternatives
 
 (
 'Uppercase' => [qw{ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }],
 'Lowercase' => [qw{ a b c d e f g h i j k l m n o p q r s t u v w x y z }],
 'Sütterlin' => [qw{ a b c d e f g h i j k l m n o p q r ſ s t u v w x y z }],
 'Old Roman Cursive' => [
-       map { /^\w/ ? '<svg width="20" height="20" viewBox="0 0 12 20"><path d="'.$_.'"/></svg>' : $_ }
+       map { m/^(-?)(\w.*)/ ? $1.'<svg width="20" height="20" viewBox="0 0 12 20"><path d="'.$2.'"/></svg>' : $_ }
        "m2,4 c1,2 8,9 8,9 M2,15 6,9",
        "m2,4 c0,0 3,-2 4,1 1,2 0,9 3,9 1,-0 2,-1 2,-1 m-6,-2 c-5,4 -0,6 1,3",
        "m4,7 4,-2 m-4,4 c0,0 -2,7 3,6",
@@ -28,7 +28,7 @@ my %C = qw(red #EC1C24  blue #3953A3  yellow #F9EC31  black #231F20);
        "m7,9 4,-0 m-8,0 c4,0 6,-1 5,6 M1,3 c2,-0 2,12 2,12",
        '>', # i = j
        "m6,8 -0,7",
-       "m9,5 -5,4 4,4 m-4,-10 -1,13",
+       "-m9,5 -5,4 4,4 m-4,-10 -1,13",
        "m3,2 c0,0 -1,9 1,10 5,2 6,2 6,2",
        "m0,16 3,-10 4,6 2,-5 5,4",
        "m2,16 1,-9 5,8 2,-9",
@@ -40,10 +40,10 @@ my %C = qw(red #EC1C24  blue #3953A3  yellow #F9EC31  black #231F20);
        "m2,7 8,0 m-4,1 c0,0 -1,8 3,5",
        '>', # u = v
        "m2,5 c0,0 3,5 6,3 3,-2 2,-3 2,-3",
-       '',
+       '-',
        "m3,19 c-1,-6 6,-17 6,-17 M1,8 c0,0 10,1 10,1",
-       "m0,7 c2,-3 5,-2 5,1 l0,11 c0,0 -0,-4 -0,-10 -0,-4 4,-4 6,-3",
-       "m3,6 c4,-1 3,3 3,3 -1,3 -2,5 -1,5 1,1 3,0 3,0",
+       "-m0,7 c2,-3 5,-2 5,1 l0,11 c0,0 -0,-4 -0,-10 -0,-4 4,-4 6,-3",
+       "-m3,6 c4,-1 3,3 3,3 -1,3 -2,5 -1,5 1,1 3,0 3,0",
 ],
 'Sutton <abbr title="American Sign Lanugage">ASL</abbr>' => [
        # American manual alphabet in Sutton (U+1D800+) notation
@@ -243,7 +243,16 @@ my %C = qw(red #EC1C24  blue #3953A3  yellow #F9EC31  black #231F20);
        )
 ],
 'Code 128' => [
-       map { tr/1-3-/❘❙❚ /r }
+       map { $U ? tr/1-3-/❘❙❚ /r : sprintf
+               '<svg width="20" height="14" viewBox="-.5 0 10 7"><path d="M0,0 %s"/></svg>',
+               join ' ',
+               map {
+                       $_ eq '' ? 'm2,-7' :
+                       $_ eq '-' ? 'm4,-7' :
+                       join 'm1,-7', ('v7') x $_
+               }
+               split /(-)?/, $_  # each bar [123] and space [ -]
+       }
        # bar widths (1-3) followed by space of width 1 (implied) or 3 (-)
        qw(
                11-2 1-12 1-1-2 12-1 1-21 1-2-1 21-1 2-11 2-1-1 123  12-3 1-23 132