From: Mischa POSLAWSKY Date: Mon, 10 Apr 2017 16:32:54 +0000 (+0200) Subject: latin: custom space glyphs in sample X-Git-Tag: v1.10~181 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/a0f942a8498d6f1574c57c5943a7d21eb9634898 latin: custom space glyphs in sample Optional 27th glyph allows altered representation (for bar codes) or styling (consistency) for whitespace in sample text (hidden in table). --- diff --git a/latin.plp b/latin.plp index ed6f65b..c9c59ad 100644 --- a/latin.plp +++ b/latin.plp @@ -119,7 +119,9 @@ else { printf '', (lc $title) =~ s/<[^>]+>//gr =~ s/\s+/-/gr; say '', $title; my $colspan = 1; + my $col = 0; for (@{$cells}) { + $col++; if ($_ eq '>') { $colspan++; next; @@ -129,6 +131,7 @@ else { print " colspan=$colspan"; $colspan = 1; } + print ' hidden' if $col > 26; # sample only print ' class=', $_ ? 'ex' : 'u-invalid' if s/^-//; print '>'; say; diff --git a/latinsample.js b/latinsample.js index c17242a..cff51e3 100644 --- a/latinsample.js +++ b/latinsample.js @@ -1,14 +1,7 @@ function appendsample() { var rows = document.getElementsByClassName('glyphs')[0].rows; for (var row of rows) { - cols = [ row.cells[0] ]; - for (var col = 1; col <= 26; col++) { - cols[col] = cols[ col - 1 ].nextSibling; - for (var span = 1; span < cols[col].colSpan; span++) { - var same = cols[col]; - cols[++col] = same; - } - } + // append sample column var samplecol = row.getElementsByClassName('sample'); if (samplecol.length) { samplecol = samplecol[0]; @@ -18,15 +11,29 @@ function appendsample() { samplecol.className = 'sample'; } + // prepare alphabet lookup table + cols = [ row.cells[0] ]; + for (var col = 1; col <= samplecol.cellIndex; col++) { + var next = cols[col - 1].nextSibling; + if (next == samplecol) break; + cols[col] = next; + for (var span = 1; span < cols[col].colSpan; span++) { + var same = cols[col]; + cols[++col] = same; + } + } + + // copy letters into sample var output = ''; var input = this.value.toUpperCase(); for (var i = 0; i < input.length; i++) { var col = input.charCodeAt(i) - 64; - if (col < 1 || col > 26) { - output += '   '; + if (col < 1) col = 27; // space + if (col < cols.length) { + output += '' + cols[col].innerHTML.trimRight() + ''; } else { - output += '' + cols[col].innerHTML.trimRight() + ''; + output += ' '; } } samplecol.innerHTML = output; diff --git a/writing-latn.inc.pl b/writing-latn.inc.pl index 3b5e5ab..e401236 100644 --- a/writing-latn.inc.pl +++ b/writing-latn.inc.pl @@ -60,6 +60,7 @@ my $U = 0; # optional unicode alternatives map { tr/01/○●/r =~ s/..\K/ /r } qw( 11000 10011 01110 10010 10000 10110 01011 00101 01100 11010 11110 01001 00111 00110 00011 01101 11101 01010 10100 00001 11100 01111 11001 10111 10101 10001 + 00100 )], 'Braille' => [qw{ ⠁ ⠃ ⠉ ⠙ ⠑ ⠋ ⠛ ⠓ ⠊ ⠚ ⠅ ⠇ ⠍ ⠝ ⠕ ⠏ ⠟ ⠗ ⠎ ⠞ â ¥ â § â º â ­ â ½ â µ }], '5-point Tactile' => [ @@ -250,7 +251,7 @@ my $U = 0; # optional unicode alternatives map { tr/012/ ❘❙/r } qw( 211012 121012 221011 112012 212011 122011 111022 211021 121021 112021 211102 121102 221101 112102 212101 122101 111202 211201 121201 112201 - 201112 102112 202111 101212 201211 102211 + 201112 102112 202111 101212 201211 102211 102121 ) ], 'Code 93' => [ @@ -268,7 +269,7 @@ my $U = 0; # optional unicode alternatives qw( 21111 21121 21131 22111 22121 23111 11211 11221 11231 12211 13211 11112 11122 11132 12112 13112 21211 21221 - 21112 21122 22112 22211 11212 11222 12212 12311 + 21112 21122 22112 22211 11212 11222 12212 12311 31121 ) ], 'Code 128' => [ @@ -277,15 +278,16 @@ my $U = 0; # optional unicode alternatives join ' ', map { $_ eq '' ? 'm2,-7' : - $_ eq '-' ? 'm4,-7' : + $_ eq '.' ? 'm3,-7' : + $_ eq ':' ? 'm4,-7' : join 'm1,-7', ('v7') x $_ } - split /(-)?/, $_ # each bar [123] and space [ -] + split /([.:])?/ # each bar [123] and space [ .:] } - # bar widths (1-3) followed by space of width 1 (implied) or 3 (-) + # bar widths (1-3) followed by space of width 1 (implied), 2 (.) 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 - 13-2 1-32 332 21-3 2-13 231 23-1 233 312 31-2 3-12 321 32-1 + 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 + 13:2 1:32 332 21:3 2:13 231 23:1 233 312 31:2 3:12 321 32:1 22.2 ) ], 'RM4SCC' => [ @@ -297,7 +299,7 @@ my $U = 0; # optional unicode alternatives ($_ & 1 ? 0 : 2), 2 + ($_ & 2) + ($_ & 1) * 2, ($_ & 1 ? 0 : 2) + 2 + ($_ & 2) + ($_ & 1) * 2, } - split //, $_ + split // } qw( 2121 2301 @@ -305,7 +307,8 @@ my $U = 0; # optional unicode alternatives 1023 1203 1221 3003 3021 3201 1032 1212 1230 3012 3030 3210 1122 1302 1320 3102 3120 3300 - ) + 0033 + ) # 0 for space ], 'Pigpen' => [ map { @@ -336,24 +339,27 @@ my $U = 0; # optional unicode alternatives . '', 'h.5v.5h-.5v-.5', # start anchor map { ['M', 'h0M', 'L']->[$_] } - split //, $_ + split // } # draw style (0=empty, 1=dot, 2=line connect) to right, down, left, up qw( 0010 0112 2022 2220 2000 2012 0122 0202 0020 0220 0012 0022 2202 - 0222 2222 0102 0200 2201 2002 2200 0100 0110 0120 2001 2010 2020 + 0222 2222 0102 0200 2201 2002 2200 0100 0110 0120 2001 2010 2020 0 ), ], 'Chromacons' => [ # Colour Alphabet by Paul Green-Armytage (2010) - map { sprintf '%s', split(/:/, $_), chr(8195) } + map { + sprintf !$_ ? '%2$s' : '%s', + split(/:/), chr(8195); + } qw{ F0A3FF:Amethyst 0075DC:Blue 993F00:Caramel 4C005C:Damson 191919:Ebony 005C31:Forest 2BCE48:Green FFCC99:Honeydew 808080:Iron 94FFB5:Jade 8F7C00:Khaki 9DCC00:Lime C20088:Mallow 003380:Navy FFA405:Orpiment FFA8BB:Pink 426600:Quagmire FF0010:Red 5EF1F2:Sky 00998F:Turquoise E0FF66:Uranium 740AFF:Violet 990000:Wine - FFFF80:Xanthin FFFF00:Yellow FF5005:Zinnia - }, + FFFF80:Xanthin FFFF00:Yellow FF5005:Zinnia 0 + } ], );