diff --git a/index.html b/index.html
index 4bffa8c..69ad34c 100644
--- a/index.html
+++ b/index.html
@@ -123,6 +123,7 @@
// Convert the 4bpp pixel indices into hex strings
let blockMap = {};
let uniques = [];
+ /*
for (let i = 0; i < chars.length; i++) {
let char = chars[i];
let block = blocks[char];
@@ -139,6 +140,43 @@
}
chars[i] = char;
}
+ */
+ for (let threshold = 0; threshold < 16; threshold++) {
+ charIter:
+ for (let i = 0; i < chars.length; i++) {
+ let char = chars[i];
+ let block = blocks[char];
+ if (!block) {
+ debugger
+ throw new Error('missing block');
+ }
+
+ fontMatch:
+ for (let j = 0; j < uniques.length; j++) {
+ let other = uniques[j];
+ if (!block) {
+ debugger
+ throw new Error('missing other');
+ }
+ for (let k = 0; k < blockWidth * blockHeight; k++) {
+ if (Math.abs(block[k] - other[k]) > threshold) {
+ continue fontMatch;
+ }
+ }
+ // we're close enough to reuse a character
+ chars[i] = j;
+ continue charIter;
+ }
+ // add a new char
+ chars[i] = uniques.push(block) - 1;
+ }
+ if (uniques.length < 128) {
+ break;
+ }
+ // We need to decimate further
+ blocks = uniques;
+ uniques = [];
+ }
let span = document.querySelector('#block-count');
span.textContent = `${uniques.length}`;