From 75b4cc203b5b9f5741f794b574b2d7d4ee4da65c Mon Sep 17 00:00:00 2001 From: David Michaud Date: Tue, 14 May 2019 11:20:04 -0400 Subject: [PATCH] replaced all new Buffer(...) by Buffer.alloc(...) and Buffer.from(...) --- src/WOFF2Font.js | 2 +- src/WOFFFont.js | 2 +- src/subset/CFFSubset.js | 2 +- src/subset/TTFSubset.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/WOFF2Font.js b/src/WOFF2Font.js index d2e0379f..c2290442 100644 --- a/src/WOFF2Font.js +++ b/src/WOFF2Font.js @@ -37,7 +37,7 @@ export default class WOFF2Font extends TTFFont { throw new Error('Error decoding compressed data in WOFF2') } - this.stream = new r.DecodeStream(new Buffer(decompressed)) + this.stream = new r.DecodeStream(Buffer.from(decompressed)) this._decompressed = true } } diff --git a/src/WOFFFont.js b/src/WOFFFont.js index d59492e9..b5ae7cbc 100644 --- a/src/WOFFFont.js +++ b/src/WOFFFont.js @@ -20,7 +20,7 @@ export default class WOFFFont extends TTFFont { if (table.compLength < table.length) { this.stream.pos += 2; // skip deflate header - let outBuffer = new Buffer(table.length); + let outBuffer = Buffer.alloc(table.length); let buf = inflate(this.stream.readBuffer(table.compLength - 2), outBuffer); return new r.DecodeStream(buf); } else { diff --git a/src/subset/CFFSubset.js b/src/subset/CFFSubset.js index 6b1da1ed..c5c9d35c 100644 --- a/src/subset/CFFSubset.js +++ b/src/subset/CFFSubset.js @@ -39,7 +39,7 @@ export default class CFFSubset extends Subset { this.cff.stream.pos = subr.offset; res.push(this.cff.stream.readBuffer(subr.length)); } else { - res.push(new Buffer([11])); // return + res.push(Buffer.from([11])); // return } } diff --git a/src/subset/TTFSubset.js b/src/subset/TTFSubset.js index d6b26f62..aa286499 100644 --- a/src/subset/TTFSubset.js +++ b/src/subset/TTFSubset.js @@ -25,7 +25,7 @@ export default class TTFSubset extends Subset { // if it is a compound glyph, include its components if (glyf && glyf.numberOfContours < 0) { - buffer = new Buffer(buffer); + buffer = Buffer.from(buffer); for (let component of glyf.components) { gid = this.includeGlyph(component.glyphID); buffer.writeUInt16BE(gid, component.pos);