pdfkit 0.17.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/js/pdfkit.es.js +20 -18
- package/js/pdfkit.es.js.map +1 -1
- package/js/pdfkit.js +20 -18
- package/js/pdfkit.js.map +1 -1
- package/js/pdfkit.standalone.js +20 -18
- package/package.json +2 -2
- package/.git-blame-ignore-revs +0 -1
package/js/pdfkit.standalone.js
CHANGED
|
@@ -223,8 +223,18 @@ class PDFReference extends PDFAbstractReference {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
const fArray = new Float32Array(1);
|
|
227
|
+
const uArray = new Uint32Array(fArray.buffer);
|
|
226
228
|
function PDFNumber(n) {
|
|
227
|
-
|
|
229
|
+
const rounded = Math.fround(n);
|
|
230
|
+
if (rounded <= n) return rounded;
|
|
231
|
+
fArray[0] = n;
|
|
232
|
+
if (n <= 0) {
|
|
233
|
+
uArray[0] += 1;
|
|
234
|
+
} else {
|
|
235
|
+
uArray[0] -= 1;
|
|
236
|
+
}
|
|
237
|
+
return fArray[0];
|
|
228
238
|
}
|
|
229
239
|
function normalizeSides(sides, defaultDefinition = undefined, transformer = v => v) {
|
|
230
240
|
if (sides == null || typeof sides === 'object' && Object.keys(sides).length === 0) {
|
|
@@ -2139,20 +2149,12 @@ oslash ugrave uacute ucircumflex
|
|
|
2139
2149
|
udieresis yacute thorn ydieresis\
|
|
2140
2150
|
`.split(/\s+/);
|
|
2141
2151
|
class AFMFont {
|
|
2142
|
-
static open(filename) {
|
|
2143
|
-
return new AFMFont(fs.readFileSync(filename, 'utf8'));
|
|
2144
|
-
}
|
|
2145
2152
|
constructor(contents) {
|
|
2146
|
-
this.contents = contents;
|
|
2147
2153
|
this.attributes = {};
|
|
2148
2154
|
this.glyphWidths = {};
|
|
2149
2155
|
this.boundingBoxes = {};
|
|
2150
2156
|
this.kernPairs = {};
|
|
2151
|
-
this.parse();
|
|
2152
|
-
this.charWidths = new Array(256);
|
|
2153
|
-
for (let char = 0; char <= 255; char++) {
|
|
2154
|
-
this.charWidths[char] = this.glyphWidths[characters[char]];
|
|
2155
|
-
}
|
|
2157
|
+
this.parse(contents);
|
|
2156
2158
|
this.bbox = this.attributes['FontBBox'].split(/\s+/).map(e => +e);
|
|
2157
2159
|
this.ascender = +(this.attributes['Ascender'] || 0);
|
|
2158
2160
|
this.descender = +(this.attributes['Descender'] || 0);
|
|
@@ -2160,9 +2162,9 @@ class AFMFont {
|
|
|
2160
2162
|
this.capHeight = +(this.attributes['CapHeight'] || 0);
|
|
2161
2163
|
this.lineGap = this.bbox[3] - this.bbox[1] - (this.ascender - this.descender);
|
|
2162
2164
|
}
|
|
2163
|
-
parse() {
|
|
2165
|
+
parse(contents) {
|
|
2164
2166
|
let section = '';
|
|
2165
|
-
for (let line of
|
|
2167
|
+
for (let line of contents.split('\n')) {
|
|
2166
2168
|
var match;
|
|
2167
2169
|
var a;
|
|
2168
2170
|
if (match = line.match(/^Start(\w+)/)) {
|
|
@@ -2815,7 +2817,7 @@ class LineWrapper extends events.EventEmitter {
|
|
|
2815
2817
|
});
|
|
2816
2818
|
}
|
|
2817
2819
|
wordWidth(word) {
|
|
2818
|
-
return this.document.widthOfString(word, this) + this.characterSpacing + this.wordSpacing;
|
|
2820
|
+
return PDFNumber(this.document.widthOfString(word, this) + this.characterSpacing + this.wordSpacing);
|
|
2819
2821
|
}
|
|
2820
2822
|
canFit(word, w) {
|
|
2821
2823
|
if (word[word.length - 1] != SOFT_HYPHEN) {
|
|
@@ -3733,8 +3735,8 @@ class PDFImage {
|
|
|
3733
3735
|
} else if (src instanceof ArrayBuffer) {
|
|
3734
3736
|
data = Buffer.from(new Uint8Array(src));
|
|
3735
3737
|
} else {
|
|
3736
|
-
|
|
3737
|
-
if (match
|
|
3738
|
+
const match = /^data:.+?;base64,(.*)$/.exec(src);
|
|
3739
|
+
if (match) {
|
|
3738
3740
|
data = Buffer.from(match[1], 'base64');
|
|
3739
3741
|
} else {
|
|
3740
3742
|
data = fs.readFileSync(src);
|
|
@@ -4821,8 +4823,8 @@ var AttachmentsMixin = {
|
|
|
4821
4823
|
} else if (src instanceof ArrayBuffer) {
|
|
4822
4824
|
data = Buffer.from(new Uint8Array(src));
|
|
4823
4825
|
} else {
|
|
4824
|
-
|
|
4825
|
-
if (match
|
|
4826
|
+
const match = /^data:(.*?);base64,(.*)$/.exec(src);
|
|
4827
|
+
if (match) {
|
|
4826
4828
|
if (match[1]) {
|
|
4827
4829
|
refBody.Subtype = match[1].replace('/', '#2F');
|
|
4828
4830
|
}
|
|
@@ -5019,7 +5021,7 @@ function deepMerge(target, ...sources) {
|
|
|
5019
5021
|
}
|
|
5020
5022
|
function deepClone(obj) {
|
|
5021
5023
|
let result = obj;
|
|
5022
|
-
if (typeof obj == 'object') {
|
|
5024
|
+
if (obj && typeof obj == 'object') {
|
|
5023
5025
|
result = Array.isArray(obj) ? [] : {};
|
|
5024
5026
|
for (const key in obj) result[key] = deepClone(obj[key]);
|
|
5025
5027
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"document",
|
|
10
10
|
"vector"
|
|
11
11
|
],
|
|
12
|
-
"version": "0.17.
|
|
12
|
+
"version": "0.17.1",
|
|
13
13
|
"homepage": "http://pdfkit.org/",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Devon Govett",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"brace": "^0.11.1",
|
|
34
34
|
"brfs": "~2.0.2",
|
|
35
35
|
"browserify": "^17.0.1",
|
|
36
|
-
"canvas": "^3.
|
|
36
|
+
"canvas": "^3.1.0",
|
|
37
37
|
"codemirror": "~5.65.18",
|
|
38
38
|
"eslint": "^9.17.0",
|
|
39
39
|
"gh-pages": "^6.2.0",
|
package/.git-blame-ignore-revs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
a76ab284a8d30c669b5ad2278bbcd050dea13abe
|