Update resourcer.js

Project configuration has weird objection to tabs.
master
stephenPspackman 2021-12-03 00:22:17 -08:00 committed by GitHub
parent 76d40a7450
commit 0d6dfca317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 28 deletions

View File

@ -63,27 +63,27 @@ const prepFont = (name, data) => {
if (m = /^(<*)(=)([*\d]*)(=*)(>*)$/.exec(line) || /^(<*)(-)(.)(-*)(>*)$/.exec(line)) { if (m = /^(<*)(=)([*\d]*)(=*)(>*)$/.exec(line) || /^(<*)(-)(.)(-*)(>*)$/.exec(line)) {
const h = m[2] == '='; const h = m[2] == '=';
if (m[1].length > desc || h && m[1].length != desc) if (m[1].length > desc || h && m[1].length != desc)
throw new Error('Invalid descender height at ' + l); throw new Error('Invalid descender height at ' + l);
if (m[2].length + m[3].length + m[4].length != body) if (m[2].length + m[3].length + m[4].length != body)
throw new Error('Invalid body height at ' + l); throw new Error('Invalid body height at ' + l);
if (m[5].length > asc || h && m[5].length != asc) if (m[5].length > asc || h && m[5].length != asc)
throw new Error('Invalid ascender height at ' + l); throw new Error('Invalid ascender height at ' + l);
if (c != null) { if (c != null) {
lengths[c] = l - o; lengths[c] = l - o;
if (width !== null && width !== lengths[c]) if (width !== null && width !== lengths[c])
throw new Error( throw new Error(
`Character has width ${lengths[c]} != ${width} at ${offsets[c]}` `Character has width ${lengths[c]} != ${width} at ${offsets[c]}`
); );
c = null c = null
} }
if (!h) { if (!h) {
c = m[3].charCodeAt(0); c = m[3].charCodeAt(0);
if (c < min) min = c; if (c < min) min = c;
if (c > max) max = c; if (c > max) max = c;
o = l + 1; o = l + 1;
offsets[c] = l; offsets[c] = l;
adjustments[c] = m[1].length adjustments[c] = m[1].length
} }
} }
}); });
const xoffs = Uint8Array(lines.length); const xoffs = Uint8Array(lines.length);
@ -92,16 +92,16 @@ const prepFont = (name, data) => {
const w0 = lengths[min]; const w0 = lengths[min];
let widths = ''; let widths = '';
for (c = min, o = 0; c <= max; c++) { for (c = min, o = 0; c <= max; c++) {
for (i = 0, j = offsets[c]; i < lengths[c]; i++) { for (i = 0, j = offsets[c]; i < lengths[c]; i++) {
xoffs[j] = asc + body + adjustments[c] - 1; xoffs[j] = asc + body + adjustments[c] - 1;
ypos[j++] = o++; ypos[j++] = o++;
} }
widths += String.fromCharCode(lengths[c]); widths += String.fromCharCode(lengths[c]);
} }
const raster = Graphics.createArrayBuffer(h, o, 1, {msb: true}); const raster = Graphics.createArrayBuffer(h, o, 1, {msb: true});
const writer = Graphics.createCallback( const writer = Graphics.createCallback(
image.width, image.height, 1, image.width, image.height, 1,
(x, y, col) => raster.setPixel(xoffs[y] - x, ypos[y], col) (x, y, col) => raster.setPixel(xoffs[y] - x, ypos[y], col)
); );
writer.drawImage(image); writer.drawImage(image);
if (width === null) width = `dec(${enc(widths)})`; if (width === null) width = `dec(${enc(widths)})`;