font-problems
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -77,3 +77,3 @@ "use strict"; | ||
else if (keyword == "BITMAP") { | ||
const rows = arrays_1.range(0, current_height).map(_ => parseInt(lines[++i], 16)); | ||
const rows = (0, arrays_1.range)(0, current_height).map(_ => parseInt(lines[++i], 16)); | ||
const width = monospace ? box_width : current_x + current_width; | ||
@@ -119,3 +119,3 @@ const glyph = glyph_1.Glyph.fromRowsBox(rows, current_width, glyph_1.BitDirection.BE, width, box_height, current_x, current_y); | ||
out.push(`CHARS ${font.glyphs.length}`); | ||
for (const i of arrays_1.range(0, font.glyphs.length)) { | ||
for (const i of (0, arrays_1.range)(0, font.glyphs.length)) { | ||
const codepoint = font.codemap[i][0]; | ||
@@ -122,0 +122,0 @@ const glyph_s_width = Math.round(font.glyphs[i].width * 1000 / height); |
@@ -115,3 +115,3 @@ "use strict"; | ||
// first, make a single array, so `sort` doesn't poop its pants. | ||
const full_array = arrays_1.range(0, this.glyphs.length).map(i => { | ||
const full_array = (0, arrays_1.range)(0, this.glyphs.length).map(i => { | ||
return [this.codemap[i][0], this.glyphs[i]]; | ||
@@ -135,3 +135,3 @@ }); | ||
if (options.reversed) { | ||
arrays_1.range(0, image.height).map(py => arrays_1.range(0, image.width).map(px => { | ||
(0, arrays_1.range)(0, image.height).map(py => (0, arrays_1.range)(0, image.width).map(px => { | ||
image.setPixel(px, py, image.isOn(px, py) ? 0 : 0xffffff); | ||
@@ -179,12 +179,12 @@ })); | ||
// convert each row & column into a number representing the "average brightness". | ||
const rows = arrays_1.range(0, image.height).map(y => average(arrays_1.range(0, image.width).map(x => image.getPixelAsGray(x, y)))); | ||
const columns = arrays_1.range(0, image.width).map(x => average(arrays_1.range(0, image.height).map(y => image.getPixelAsGray(x, y)))); | ||
const rows = (0, arrays_1.range)(0, image.height).map(y => average((0, arrays_1.range)(0, image.width).map(x => image.getPixelAsGray(x, y)))); | ||
const columns = (0, arrays_1.range)(0, image.width).map(x => average((0, arrays_1.range)(0, image.height).map(y => image.getPixelAsGray(x, y)))); | ||
// average the "average brightness" values for every line along an | ||
// interval, with a small penalty to larger intervals. | ||
function checkInterval(lines, interval) { | ||
return average(arrays_1.range(interval, lines.length, interval).map(i => lines[i - 1])) * Math.pow(0.995, interval); | ||
return average((0, arrays_1.range)(interval, lines.length, interval).map(i => lines[i - 1])) * Math.pow(0.995, interval); | ||
} | ||
function pickBestInterval(lines, low, high) { | ||
// try intervals that evenly divide into the number of lines. | ||
const intervals = arrays_1.range(low, high).filter(n => n < lines.length && lines.length % n == 0); | ||
const intervals = (0, arrays_1.range)(low, high).filter(n => n < lines.length && lines.length % n == 0); | ||
return intervals.map(n => ({ n, weight: checkInterval(lines, n) })).sort((a, b) => { | ||
@@ -196,3 +196,3 @@ // by highest weight, and in case of tie, by smallest n. | ||
return { | ||
width: pickBestInterval(columns, 4, 17), | ||
width: pickBestInterval(columns, 4, 21), | ||
height: pickBestInterval(rows, 6, 33) | ||
@@ -199,0 +199,0 @@ }; |
@@ -17,3 +17,3 @@ "use strict"; | ||
function defaultCodemap(count, start = 0) { | ||
return arrays_1.range(0, count).map(n => [start + n]); | ||
return (0, arrays_1.range)(0, count).map(n => [start + n]); | ||
} | ||
@@ -32,3 +32,3 @@ exports.defaultCodemap = defaultCodemap; | ||
}); | ||
const codemap = arrays_1.range(0, count).map(_ => []); | ||
const codemap = (0, arrays_1.range)(0, count).map(_ => []); | ||
lines.forEach((line, lineno) => { | ||
@@ -51,4 +51,6 @@ try { | ||
catch (error) { | ||
process.stderr.write(`Error parsing codemap at line ${lineno + 1}: ${error.message}\n`); | ||
process.stderr.write(` ${line}\n`); | ||
if (error instanceof Error) { | ||
process.stderr.write(`Error parsing codemap at line ${lineno + 1}: ${error.message}\n`); | ||
process.stderr.write(` ${line}\n`); | ||
} | ||
throw error; | ||
@@ -55,0 +57,0 @@ } |
@@ -32,3 +32,3 @@ "use strict"; | ||
buffer[py + font.cellHeight].push(label); | ||
arrays_1.range(label.length, width).forEach(_ => buffer[py + font.cellHeight].push(" ")); | ||
(0, arrays_1.range)(label.length, width).forEach(_ => buffer[py + font.cellHeight].push(" ")); | ||
}); | ||
@@ -46,2 +46,9 @@ return buffer.map(line => line.join("")); | ||
let text = ""; | ||
text += `\ | ||
/* | ||
* font header auto-generated by font-problems: | ||
* https://github.com/robey/font-problems/ | ||
*/ | ||
`; | ||
text += `/* ${desc} */\n\n`; | ||
@@ -86,2 +93,4 @@ text += `const int ${name}_font_glyphs = ${font.glyphs.length};\n`; | ||
let text = ""; | ||
text += `// font header auto-generated by font-problems:\n`; | ||
text += `// https://github.com/robey/font-problems/\n\n`; | ||
text += `// ${desc}\n\n`; | ||
@@ -121,2 +130,4 @@ text += `${dead}pub const FONT_GLYPHS: usize = ${font.glyphs.length};\n`; | ||
text += `import binascii\n\n`; | ||
text += `# font header auto-generated by font-problems:\n`; | ||
text += `# https://github.com/robey/font-problems/\n\n`; | ||
text += `# ${desc}\n`; | ||
@@ -123,0 +134,0 @@ if (font.isMonospace) |
@@ -17,2 +17,3 @@ "use strict"; | ||
const psf_1 = require("./psf"); | ||
const taf_1 = require("./taf"); | ||
require("source-map-support/register"); | ||
@@ -95,2 +96,4 @@ const USAGE = ` | ||
(for GFX) use a baseline N pixels up from the bottom of the glyph | ||
--name <name> | ||
use a specific font name when exporting (if the format supports names) | ||
--fg <hex> | ||
@@ -149,2 +152,3 @@ foreground color (default "000000") when writing a BMP file | ||
"map", | ||
"name", | ||
"ppad", | ||
@@ -199,3 +203,3 @@ "rowsize", | ||
const fb = writeSample(options, font, options.sample); | ||
fs.writeFileSync(outFilename, bmp_1.writeBmp(fb)); | ||
fs.writeFileSync(outFilename, (0, bmp_1.writeBmp)(fb)); | ||
verbose(options, `Wrote sample text (${fb.width} x ${fb.height}) to file: ${outFilename}`); | ||
@@ -207,3 +211,3 @@ } | ||
const mapFilename = outFilename.replace(/\.\w+$/, ".psfmap"); | ||
fs.writeFileSync(mapFilename, codemap_1.dumpCodemap(font.codemap)); | ||
fs.writeFileSync(mapFilename, (0, codemap_1.dumpCodemap)(font.codemap)); | ||
verbose(options, `Wrote codemap file: ${mapFilename}`); | ||
@@ -215,3 +219,3 @@ } | ||
const rowsize = parseInt(options.termwidth, 10); | ||
export_font_1.exportAscii(font, rowsize).forEach(line => process.stdout.write(line + "\n")); | ||
(0, export_font_1.exportAscii)(font, rowsize).forEach(line => process.stdout.write(line + "\n")); | ||
} | ||
@@ -232,7 +236,9 @@ } | ||
case ".psf": | ||
return psf_1.readPsf(fs.readFileSync(filename)); | ||
return (0, psf_1.readPsf)(fs.readFileSync(filename)); | ||
case ".bdf": | ||
return bdf_1.read_bdf(fs.readFileSync(filename), options.monospace); | ||
return (0, bdf_1.read_bdf)(fs.readFileSync(filename), options.monospace); | ||
case ".taf": | ||
return (0, taf_1.readTaf)(fs.readFileSync(filename))[0]; | ||
case ".bmp": | ||
const fb = bmp_1.readBmp(fs.readFileSync(filename)); | ||
const fb = (0, bmp_1.readBmp)(fs.readFileSync(filename)); | ||
const importOptions = { | ||
@@ -249,3 +255,3 @@ isMonospace: options.monospace, | ||
if (options.map) | ||
font.codemap = codemap_1.parseCodemap(font.glyphs.length, fs.readFileSync(options.map).toString()); | ||
font.codemap = (0, codemap_1.parseCodemap)(font.glyphs.length, fs.readFileSync(options.map).toString()); | ||
return font; | ||
@@ -269,3 +275,3 @@ case ".c": | ||
}; | ||
return gfx_1.read_gfx(text, gfxOptions); | ||
return (0, gfx_1.read_gfx)(text, gfxOptions); | ||
} | ||
@@ -280,3 +286,3 @@ const headerImportOptions = { | ||
}; | ||
return import_font_1.importHeader(text, headerImportOptions); | ||
return (0, import_font_1.importHeader)(text, headerImportOptions); | ||
} | ||
@@ -288,13 +294,19 @@ default: | ||
function saveFont(options, font, filename, ext) { | ||
var _a; | ||
if (!ext) | ||
ext = path.extname(filename); | ||
const name = (_a = options.name) !== null && _a !== void 0 ? _a : path.basename(filename, ext); | ||
switch (ext) { | ||
case ".psf": | ||
fs.writeFileSync(filename, psf_1.writePsf(font, { withMap: true })); | ||
fs.writeFileSync(filename, (0, psf_1.writePsf)(font, { withMap: true })); | ||
verbose(options, `Wrote PSF file: ${filename}`); | ||
return; | ||
case ".bdf": | ||
fs.writeFileSync(filename, bdf_1.write_bdf(font, path.basename(filename))); | ||
fs.writeFileSync(filename, (0, bdf_1.write_bdf)(font, name)); | ||
verbose(options, `Wrote BDF file: ${filename}`); | ||
return; | ||
case ".taf": | ||
fs.writeFileSync(filename, (0, taf_1.writeTaf)(font, name, options.vertical)); | ||
verbose(options, `Wrote TAF file: ${filename}`); | ||
return; | ||
case ".bmp": { | ||
@@ -304,3 +316,3 @@ const rowsize = parseInt(options.rowsize, 10); | ||
const fb = font.dumpIntoFramebuffer(rowsize, fg, bg); | ||
fs.writeFileSync(filename, bmp_1.writeBmp(fb)); | ||
fs.writeFileSync(filename, (0, bmp_1.writeBmp)(fb)); | ||
verbose(options, `Wrote ${fb.width} x ${fb.height} BMP file: ${filename}`); | ||
@@ -312,3 +324,3 @@ return; | ||
const baseline = options.baseline ? parseInt(options.baseline, 10) : undefined; | ||
fs.writeFileSync(filename, gfx_1.write_gfx(font, path.basename(filename, ext), baseline)); | ||
fs.writeFileSync(filename, (0, gfx_1.write_gfx)(font, name, baseline)); | ||
verbose(options, `Wrote GFX header file: ${filename}`); | ||
@@ -328,3 +340,3 @@ return; | ||
cOptions.includeCodemap = true; | ||
fs.writeFileSync(filename, export_font_1.exportC(path.basename(filename, ext), font, cOptions)); | ||
fs.writeFileSync(filename, (0, export_font_1.exportC)(name, font, cOptions)); | ||
const endian = cOptions.direction == glyph_1.BitDirection.LE ? "little" : "big"; | ||
@@ -347,3 +359,3 @@ const orientation = cOptions.columns ? "columns" : "rows"; | ||
cOptions.includeCodemap = true; | ||
fs.writeFileSync(filename, export_font_1.exportRust(path.basename(filename, ext), font, cOptions)); | ||
fs.writeFileSync(filename, (0, export_font_1.exportRust)(name, font, cOptions)); | ||
const endian = cOptions.direction == glyph_1.BitDirection.LE ? "little" : "big"; | ||
@@ -366,3 +378,3 @@ const orientation = cOptions.columns ? "columns" : "rows"; | ||
cOptions.includeCodemap = true; | ||
fs.writeFileSync(filename, export_font_1.exportPython(path.basename(filename, ext), font, cOptions)); | ||
fs.writeFileSync(filename, (0, export_font_1.exportPython)(name, font, cOptions)); | ||
const endian = cOptions.direction == glyph_1.BitDirection.LE ? "little" : "big"; | ||
@@ -379,3 +391,3 @@ const orientation = cOptions.columns ? "columns" : "rows"; | ||
bOptions.direction = glyph_1.BitDirection.BE; | ||
fs.writeFileSync(filename, export_font_1.exportBin(font, bOptions)); | ||
fs.writeFileSync(filename, (0, export_font_1.exportBin)(font, bOptions)); | ||
const endian = bOptions.direction == glyph_1.BitDirection.LE ? "little" : "big"; | ||
@@ -382,0 +394,0 @@ const orientation = bOptions.columns ? "columns" : "rows"; |
@@ -50,4 +50,4 @@ "use strict"; | ||
averageBrightness() { | ||
return arrays_1.range(0, this.height).reduce((sum, y) => { | ||
return sum + arrays_1.range(0, this.width).reduce((sum, x) => sum + this.getPixelAsGray(x, y), 0); | ||
return (0, arrays_1.range)(0, this.height).reduce((sum, y) => { | ||
return sum + (0, arrays_1.range)(0, this.width).reduce((sum, x) => sum + this.getPixelAsGray(x, y), 0); | ||
}, 0) / (this.width * this.height); | ||
@@ -54,0 +54,0 @@ } |
@@ -67,3 +67,3 @@ "use strict"; | ||
const [firstPoint, lastPoint, height] = numbers; | ||
const glyphData = import_font_1.matchAll(reg(NUMBER_LIST), glyphCode[1]).map(m => parseNumbers(m[0])); | ||
const glyphData = (0, import_font_1.matchAll)(reg(NUMBER_LIST), glyphCode[1]).map(m => parseNumbers(m[0])); | ||
const bitmapData = parseNumbers(bitmapCode[1]); | ||
@@ -84,3 +84,3 @@ // if this is monospace, and no width was provided, assume the widest glyph | ||
const font = new bitmap_font_1.BitmapFont(options.monospace); | ||
for (const point of arrays_1.range(firstPoint, lastPoint + 1)) { | ||
for (const point of (0, arrays_1.range)(firstPoint, lastPoint + 1)) { | ||
const [index, boxWidth, boxHeight, width, xOffset, yBaseOffset] = glyphData[point - firstPoint]; | ||
@@ -101,3 +101,3 @@ const yOffset = height + yBaseOffset - yCorrect; | ||
function parseNumbers(s) { | ||
return import_font_1.matchAll(reg(NUMBER), s).map(m => { | ||
return (0, import_font_1.matchAll)(reg(NUMBER), s).map(m => { | ||
if (m[0].startsWith("0x")) { | ||
@@ -142,3 +142,3 @@ return parseInt(m[0].slice(2), 16); | ||
const glyphs = []; | ||
for (const i of arrays_1.range(0, font.glyphs.length)) { | ||
for (const i of (0, arrays_1.range)(0, font.glyphs.length)) { | ||
const glyph = font.glyphs[i]; | ||
@@ -150,3 +150,3 @@ const box = glyph.packIntoPackedRows(glyph_1.BitDirection.BE); | ||
} | ||
const bitmapString = arrays_1.arrayGrouped(bitmap, 8).map(row => { | ||
const bitmapString = (0, arrays_1.arrayGrouped)(bitmap, 8).map(row => { | ||
return " " + row.map(n => hex(n) + ", ").join("").trim(); | ||
@@ -153,0 +153,0 @@ }).join("\n"); |
@@ -25,6 +25,6 @@ "use strict"; | ||
get rawHex() { | ||
return arrays_1.range(0, this.data.length).map(i => ("0" + this.data[i].toString(16)).slice(-2)).join(""); | ||
return (0, arrays_1.range)(0, this.data.length).map(i => ("0" + this.data[i].toString(16)).slice(-2)).join(""); | ||
} | ||
debug(joiner = "\n") { | ||
return arrays_1.range(0, this.height).map(y => arrays_1.range(0, this.width).map(x => this.getPixel(x, y) ? "@" : " ").join("")).join(joiner); | ||
return (0, arrays_1.range)(0, this.height).map(y => (0, arrays_1.range)(0, this.width).map(x => this.getPixel(x, y) ? "@" : " ").join("")).join(joiner); | ||
} | ||
@@ -88,10 +88,10 @@ getPixel(x, y) { | ||
let x0 = 0, y0 = 0, x1 = this.width, y1 = this.height; | ||
while (x0 < x1 && arrays_1.range(y0, y1).every(y => !this.getPixel(x0, y))) | ||
while (x0 < x1 && (0, arrays_1.range)(y0, y1).every(y => !this.getPixel(x0, y))) | ||
x0++; | ||
while (x0 < x1 && arrays_1.range(y0, y1).every(y => !this.getPixel(x1 - 1, y))) | ||
while (x0 < x1 && (0, arrays_1.range)(y0, y1).every(y => !this.getPixel(x1 - 1, y))) | ||
x1--; | ||
if (x0 < x1) { | ||
while (y0 < y1 && arrays_1.range(x0, x1).every(x => !this.getPixel(x, y0))) | ||
while (y0 < y1 && (0, arrays_1.range)(x0, x1).every(x => !this.getPixel(x, y0))) | ||
y0++; | ||
while (y0 < y1 && arrays_1.range(x0, x1).every(x => !this.getPixel(x, y1 - 1))) | ||
while (y0 < y1 && (0, arrays_1.range)(x0, x1).every(x => !this.getPixel(x, y1 - 1))) | ||
y1--; | ||
@@ -144,3 +144,3 @@ } | ||
if (!isMonospace) { | ||
while (width > 0 && arrays_1.range(0, fb.height).every(y => fb.isOn(width - 1, y))) | ||
while (width > 0 && (0, arrays_1.range)(0, fb.height).every(y => fb.isOn(width - 1, y))) | ||
width--; | ||
@@ -185,4 +185,4 @@ // what about "space"? for a proportional font, use 1/2 the total width. | ||
let bit = 0, byte = 0; | ||
for (const y of arrays_1.range(0, boxHeight)) { | ||
for (const x of arrays_1.range(0, boxWidth)) { | ||
for (const y of (0, arrays_1.range)(0, boxHeight)) { | ||
for (const x of (0, arrays_1.range)(0, boxWidth)) { | ||
const px = direction == BitDirection.BE ? 8 - bit - 1 : bit; | ||
@@ -189,0 +189,0 @@ if (((rows[byte] >>> px) & 1) != 0) |
@@ -46,3 +46,3 @@ "use strict"; | ||
const font = new bitmap_font_1.BitmapFont(true); | ||
for (const i of arrays_1.range(0, glyph_count)) { | ||
for (const i of (0, arrays_1.range)(0, glyph_count)) { | ||
const offset = i * glyph_size; | ||
@@ -49,0 +49,0 @@ const glyph_data = data.slice(offset, offset + glyph_size); |
"use strict"; | ||
// for exporting as a library | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.writePsf = exports.readPsf = exports.Glyph = exports.BitDirection = exports.Framebuffer = exports.writeBmp = exports.readBmp = exports.BitmapFont = exports.write_bdf = exports.read_bdf = void 0; | ||
var bdf_1 = require("./bdf"); | ||
@@ -5,0 +6,0 @@ Object.defineProperty(exports, "read_bdf", { enumerable: true, get: function () { return bdf_1.read_bdf; } }); |
@@ -97,6 +97,6 @@ "use strict"; | ||
readUnicodeTable(new Position(buffer, headerSize + glyphCount * glyphSize), glyphCount, true) : | ||
codemap_1.defaultCodemap(glyphCount); | ||
(0, codemap_1.defaultCodemap)(glyphCount); | ||
let index = headerSize; | ||
for (let i = 0; i < glyphCount; i++) { | ||
const rows = arrays_1.range(0, cellHeight).map(y => { | ||
const rows = (0, arrays_1.range)(0, cellHeight).map(y => { | ||
return rowsize == 2 ? buffer.readUInt16BE(index + y * rowsize) : buffer.readUInt8(index + y * rowsize); | ||
@@ -118,3 +118,3 @@ }); | ||
readUnicodeTable(new Position(buffer, 4 + glyphCount * glyphSize), glyphCount, false) : | ||
codemap_1.defaultCodemap(glyphCount); | ||
(0, codemap_1.defaultCodemap)(glyphCount); | ||
let index = 4; | ||
@@ -136,3 +136,3 @@ for (let i = 0; i < glyphCount; i++) { | ||
function readUnicodeTable(pos, count, utf8) { | ||
return arrays_1.range(0, count).map(i => { | ||
return (0, arrays_1.range)(0, count).map(i => { | ||
// each glyph has a sequence of code points, optionally followed by a | ||
@@ -139,0 +139,0 @@ // sequence of (STARTSEQ codepoint*), followed by SEPARATOR. |
@@ -14,3 +14,3 @@ "use strict"; | ||
const bdf = fs.readFileSync("./src/test/data/9c56eef5-tom-thumber.bdf"); | ||
const font = bdf_1.read_bdf(bdf, true); | ||
const font = (0, bdf_1.read_bdf)(bdf, true); | ||
(_a = font.find("!")) === null || _a === void 0 ? void 0 : _a.rawHex.should.eql("222000"); | ||
@@ -27,3 +27,3 @@ (_b = font.find("\"")) === null || _b === void 0 ? void 0 : _b.rawHex.should.eql("550000"); | ||
const bdf = fs.readFileSync("./src/test/data/steinbeck.bdf"); | ||
const font = bdf_1.read_bdf(bdf, false); | ||
const font = (0, bdf_1.read_bdf)(bdf, false); | ||
(_a = font.find(" ")) === null || _a === void 0 ? void 0 : _a.width.should.eql(1); | ||
@@ -30,0 +30,0 @@ (_b = font.find(" ")) === null || _b === void 0 ? void 0 : _b.debug(",").should.eql(" , , , , , , , "); |
@@ -85,10 +85,10 @@ "use strict"; | ||
function loadBmp(filename) { | ||
return bmp_1.readBmp(fs.readFileSync(`src/test/data/${filename}`)); | ||
return (0, bmp_1.readBmp)(fs.readFileSync(`src/test/data/${filename}`)); | ||
} | ||
bitmap_font_1.sniffBoundaries(loadBmp("tom-thumb-256.bmp")).should.eql({ width: 4, height: 6 }); | ||
bitmap_font_1.sniffBoundaries(loadBmp("lolathin.bmp")).should.eql({ width: 6, height: 8 }); | ||
bitmap_font_1.sniffBoundaries(loadBmp("lola12.bmp")).should.eql({ width: 6, height: 12 }); | ||
(0, bitmap_font_1.sniffBoundaries)(loadBmp("tom-thumb-256.bmp")).should.eql({ width: 4, height: 6 }); | ||
(0, bitmap_font_1.sniffBoundaries)(loadBmp("lolathin.bmp")).should.eql({ width: 6, height: 8 }); | ||
(0, bitmap_font_1.sniffBoundaries)(loadBmp("lola12.bmp")).should.eql({ width: 6, height: 12 }); | ||
}); | ||
it("loads from a framebuffer", () => { | ||
const fb = bmp_1.readBmp(fs.readFileSync("src/test/data/lolathin.bmp")); | ||
const fb = (0, bmp_1.readBmp)(fs.readFileSync("src/test/data/lolathin.bmp")); | ||
const font = bitmap_font_1.BitmapFont.importFromImage(fb, { isMonospace: false }); | ||
@@ -109,3 +109,3 @@ font.isMonospace.should.eql(false); | ||
it("packs into rows", () => { | ||
const fb = bmp_1.readBmp(fs.readFileSync("src/test/data/tom-thumb-256.bmp")); | ||
const fb = (0, bmp_1.readBmp)(fs.readFileSync("src/test/data/tom-thumb-256.bmp")); | ||
const font = bitmap_font_1.BitmapFont.importFromImage(fb); | ||
@@ -122,3 +122,3 @@ const ee = font.glyphs[0x45]; | ||
it("packs into columns", () => { | ||
const fb = bmp_1.readBmp(fs.readFileSync("src/test/data/tom-thumb-256.bmp")); | ||
const fb = (0, bmp_1.readBmp)(fs.readFileSync("src/test/data/tom-thumb-256.bmp")); | ||
const font = bitmap_font_1.BitmapFont.importFromImage(fb); | ||
@@ -125,0 +125,0 @@ const ee = font.glyphs[0x45]; |
@@ -10,3 +10,3 @@ "use strict"; | ||
it("read a test image", () => { | ||
let f = bmp_1.readBmp(fs.readFileSync("./src/test/data/test.bmp")); | ||
let f = (0, bmp_1.readBmp)(fs.readFileSync("./src/test/data/test.bmp")); | ||
f.width.should.eql(4); | ||
@@ -27,4 +27,4 @@ f.height.should.eql(4); | ||
f.setPixel(1, 1, 0xaabbcc); | ||
const data = bmp_1.writeBmp(f); | ||
let f2 = bmp_1.readBmp(data); | ||
const data = (0, bmp_1.writeBmp)(f); | ||
let f2 = (0, bmp_1.readBmp)(data); | ||
f2.width.should.eql(2); | ||
@@ -31,0 +31,0 @@ f2.height.should.eql(2); |
@@ -14,3 +14,3 @@ "use strict"; | ||
]; | ||
codemap_1.dumpCodemap(map).should.eql("0: 40\n" + | ||
(0, codemap_1.dumpCodemap)(map).should.eql("0: 40\n" + | ||
"1: 41\n" + | ||
@@ -24,9 +24,9 @@ "2: 42\n" + | ||
it("empty", () => { | ||
codemap_1.parseCodemap(2, "").should.eql([[], []]); | ||
(0, codemap_1.parseCodemap)(2, "").should.eql([[], []]); | ||
}); | ||
it("comments and whitespace", () => { | ||
codemap_1.parseCodemap(3, " # wut\n\n 1 : 0040 \n\n0:20 \n").should.eql([[0x20], [0x40], []]); | ||
(0, codemap_1.parseCodemap)(3, " # wut\n\n 1 : 0040 \n\n0:20 \n").should.eql([[0x20], [0x40], []]); | ||
}); | ||
it("ranges", () => { | ||
codemap_1.parseCodemap(10, "0: 41\n1: 42 - 44\n6: 45-47").should.eql([ | ||
(0, codemap_1.parseCodemap)(10, "0: 41\n1: 42 - 44\n6: 45-47").should.eql([ | ||
[0x41], [0x42], [0x43], [0x44], [], [], [0x45], [0x46], [0x47], [] | ||
@@ -38,5 +38,5 @@ ]); | ||
const description = fs.readFileSync("./src/test/data/Lat15-Terminus32x16.psfmap").toString(); | ||
codemap_1.dumpCodemap(codemap_1.parseCodemap(256, description)).should.eql(description); | ||
(0, codemap_1.dumpCodemap)((0, codemap_1.parseCodemap)(256, description)).should.eql(description); | ||
}); | ||
}); | ||
//# sourceMappingURL=test_codemap.js.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
const gfx = fs.readFileSync("./src/test/data/TomThumb.h").toString(); | ||
const font = gfx_1.read_gfx(gfx, { monospace: true }); | ||
const font = (0, gfx_1.read_gfx)(gfx, { monospace: true }); | ||
(_a = font.find("!")) === null || _a === void 0 ? void 0 : _a.rawHex.should.eql("110101"); | ||
@@ -24,7 +24,7 @@ (_b = font.find("\"")) === null || _b === void 0 ? void 0 : _b.rawHex.should.eql("550000"); | ||
const gfx = fs.readFileSync("./src/test/data/TomThumb.h").toString(); | ||
const font = gfx_1.read_gfx(gfx, { monospace: true }); | ||
const font = (0, gfx_1.read_gfx)(gfx, { monospace: true }); | ||
const gfx2 = fs.readFileSync("./src/test/data/foo.h").toString(); | ||
gfx_1.write_gfx(font, "foo", 1).should.eql(gfx2); | ||
(0, gfx_1.write_gfx)(font, "foo", 1).should.eql(gfx2); | ||
}); | ||
}); | ||
//# sourceMappingURL=test_gfx.js.map |
@@ -16,3 +16,3 @@ "use strict"; | ||
it("reads a font", () => { | ||
const font = psf_1.readPsf(fs.readFileSync("./src/test/data/tom-thumb-256.psf")); | ||
const font = (0, psf_1.readPsf)(fs.readFileSync("./src/test/data/tom-thumb-256.psf")); | ||
font.cellHeight.should.eql(6); | ||
@@ -33,4 +33,4 @@ font.glyphs[0x4d].width.should.eql(4); | ||
const data1 = fs.readFileSync("./src/test/data/tom-thumb-256.psf"); | ||
const font = psf_1.readPsf(data1); | ||
const data2 = psf_1.writePsf(font, { withMap: true }); | ||
const font = (0, psf_1.readPsf)(data1); | ||
const data2 = (0, psf_1.writePsf)(font, { withMap: true }); | ||
data1.toString("hex").should.eql(data2.toString("hex")); | ||
@@ -37,0 +37,0 @@ }); |
{ | ||
"name": "font-problems", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "command-line tools for font formats", | ||
@@ -22,3 +22,3 @@ "repository": { | ||
"source-map-support": "^0.5.19", | ||
"typescript": "^3.9.6" | ||
"typescript": "^4.7.3" | ||
}, | ||
@@ -25,0 +25,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
3292064
105
2659