latin: support repeat glyph substitution in sample
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 10 Apr 2017 17:49:03 +0000 (19:49 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 24 Apr 2017 23:51:41 +0000 (01:51 +0200)
Optional 28th glyph to be shown instead of a doubled letter in sample texts.

latinsample.js

index cff51e38b9e295869fca2bde87eb49b0037509df..b576f955514949eb24c59f3c4d93619824a6fe88 100644 (file)
@@ -29,8 +29,12 @@ function appendsample() {
                for (var i = 0; i < input.length; i++) {
                        var col = input.charCodeAt(i) - 64;
                        if (col < 1) col = 27; // space
                for (var i = 0; i < input.length; i++) {
                        var col = input.charCodeAt(i) - 64;
                        if (col < 1) col = 27; // space
+                       else if (cols[28] && i && col == input.charCodeAt(i - 1) - 64) {
+                               col = 28; // repetition char
+                       }
+
                        if (col < cols.length) {
                        if (col < cols.length) {
-                               output += '<span>' + cols[col].innerHTML.trimRight() + '</span>';
+                               output += '<span>' + (cols[col].innerHTML.trimRight() || ' ') + '</span>';
                        }
                        else {
                                output += ' ';
                        }
                        else {
                                output += ' ';