Skip to content

Commit d0ffa72

Browse files
committed
make eslint happy
1 parent e4a2406 commit d0ffa72

File tree

2 files changed

+38
-43
lines changed

2 files changed

+38
-43
lines changed

bin/ot

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env node
22
/* eslint no-console: off */
33

4-
const process = require('process')
5-
, fs = require('fs')
6-
, path = require('path')
7-
, { load, woffToOTF } = require('../dist/opentype.js')
8-
;
4+
const process = require('process'),
5+
fs = require('fs'),
6+
path = require('path'),
7+
{ load, woffToOTF } = require('../dist/opentype.js');
98

109
// Print out information about the font on the console.
1110
function printFontInfo(font) {
@@ -90,15 +89,14 @@ if (process.argv.length < 3) {
9089
}
9190
const fontpath = process.argv[3];
9291
if (!fs.existsSync(fontpath)) {
93-
console.log(`Font file at path not found.`);
92+
console.log('Font file at path not found.');
9493
process.exit(1);
9594
}
9695
const targetPath = process.argv.length >= 5
9796
? process.argv[4]
98-
: `${path.join(path.dirname(fontpath), path.basename(fontpath, path.extname(fontpath)))}.otf`
99-
, buffer = fs.readFileSync(fontpath)
100-
, result = woffToOTF(buffer)
101-
;
97+
: `${path.join(path.dirname(fontpath), path.basename(fontpath, path.extname(fontpath)))}.otf`,
98+
buffer = fs.readFileSync(fontpath),
99+
result = woffToOTF(buffer);
102100
fs.writeFileSync(targetPath, new DataView(result));
103101
} else {
104102
printUsage();

src/opentype.mjs

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -476,68 +476,65 @@ function loadSync() {
476476
function woffToOTF(buffer) {
477477
if (buffer.constructor !== ArrayBuffer)
478478
buffer = new Uint8Array(buffer).buffer;
479-
const data = new DataView(buffer, 0)
480-
, out = []
481-
, signature = parse.getTag(data, 0)
482-
;
479+
480+
const data = new DataView(buffer, 0),
481+
out = [],
482+
signature = parse.getTag(data, 0);
483483

484484
if (signature !== 'wOFF')
485485
throw new Error(`TYPE ERROR signature must be wOFF but is: "${signature}"`);
486486

487-
const flavor = parse.getTag(data, 4)
488-
, numTables = parse.getUShort(data, 12)
489-
, tableEntries = parseWOFFTableEntries(data, numTables)
490-
, max = []
491-
;
487+
const flavor = parse.getTag(data, 4),
488+
numTables = parse.getUShort(data, 12),
489+
tableEntries = parseWOFFTableEntries(data, numTables),
490+
max = [];
492491
for (let n = 0; n < 64; n++) {
493492
if (Math.pow(2, n) > numTables)
494493
break;
495494
max.splice(0, Infinity, n, 2 ** n);
496495
}
497-
const searchRange = max[1] * 16
498-
, entrySelector = max[0]
499-
, rangeShift = numTables * 16 - searchRange
500-
;
496+
497+
const searchRange = max[1] * 16,
498+
entrySelector = max[0],
499+
rangeShift = numTables * 16 - searchRange;
501500

502501
out.push(
503-
...encode.TAG(flavor)
504-
, ...encode.USHORT(numTables)
505-
, ...encode.USHORT(searchRange)
506-
, ...encode.USHORT(entrySelector)
507-
, ...encode.USHORT(rangeShift)
502+
...encode.TAG(flavor),
503+
...encode.USHORT(numTables),
504+
...encode.USHORT(searchRange),
505+
...encode.USHORT(entrySelector),
506+
...encode.USHORT(rangeShift)
508507
);
509508
let offset = out.length + numTables * 16;
510509

511510
for (let i=0; i<numTables; i++) {
512511
const tableEntry = tableEntries[i];
513512
out.push(
514-
...encode.TAG(tableEntry.tag)
515-
, ...encode.ULONG(tableEntry.checksum)
516-
, ...encode.ULONG(offset)
517-
, ...encode.ULONG(tableEntry.length)
513+
...encode.TAG(tableEntry.tag),
514+
...encode.ULONG(tableEntry.checksum),
515+
...encode.ULONG(offset),
516+
...encode.ULONG(tableEntry.length)
518517
);
519518
tableEntry.outOffset = offset;
520519
offset += tableEntry.length;
521520
if ((offset % 4) !== 0)
522521
offset += 4 - (offset % 4);
523522
}
524-
const initialData = new Uint8Array(out.length)
525-
, buffers = [initialData]
526-
;
523+
const initialData = new Uint8Array(out.length),
524+
buffers = [initialData];
527525
for (let i=0,l=out.length; i<l; i++)
528526
initialData[i] = out[i];
529527

530528
for (let i=0; i<numTables; i++) {
531-
const tableEntry = tableEntries[i]
532-
, table = uncompressTable(data, tableEntry) // => {data: view, offset: 0};
533-
, offset = tableEntry.outOffset + tableEntry.length
534-
, padding = (offset % 4) !== 0
529+
const tableEntry = tableEntries[i],
530+
table = uncompressTable(data, tableEntry), // => {data: view, offset: 0};
531+
offset = tableEntry.outOffset + tableEntry.length,
532+
padding = (offset % 4) !== 0
535533
? 4 - (offset % 4)
536-
: 0
537-
;
534+
: 0;
538535
buffers.push(
539-
new Uint8Array(table.data.buffer, table.offset, tableEntry.length)
540-
, new Uint8Array(padding)
536+
new Uint8Array(table.data.buffer, table.offset, tableEntry.length),
537+
new Uint8Array(padding)
541538
);
542539
}
543540
const result = new Uint8Array(buffers.reduce((accum, buffer)=>accum+buffer.byteLength, 0));

0 commit comments

Comments
 (0)