pdf-parser.js 5.2.26 → 5.2.28
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/dist/{afm-widths-BYiX2L9D.cjs → afm-widths-BHD2HZIL.cjs} +553 -642
- package/dist/{afm-widths-blUDDjlI.js → afm-widths-B_IGbGky.js} +553 -642
- package/dist/afm-widths.cjs +1 -1
- package/dist/afm-widths.js +1 -1
- package/dist/annotations.cjs +5 -3
- package/dist/annotations.d.cts +2 -2
- package/dist/annotations.d.ts +2 -2
- package/dist/annotations.js +5 -3
- package/dist/attachments.d.cts +2 -2
- package/dist/attachments.d.ts +2 -2
- package/dist/builtin-encoding.cjs +17 -6
- package/dist/builtin-encoding.js +17 -6
- package/dist/bytes/crc32.cjs +5 -3
- package/dist/bytes/crc32.js +5 -3
- package/dist/bytes/flate.cjs +0 -1
- package/dist/bytes/flate.js +0 -1
- package/dist/cff-bounds.cjs +73 -45
- package/dist/cff-bounds.js +73 -45
- package/dist/cff.cjs +13 -6
- package/dist/cff.js +13 -6
- package/dist/cmap-table.cjs +54 -26
- package/dist/cmap-table.js +54 -26
- package/dist/cmap.cjs +5 -3
- package/dist/cmap.js +5 -3
- package/dist/content-read.d.cts +1 -1
- package/dist/content-read.d.ts +1 -1
- package/dist/content-write.cjs +21 -14
- package/dist/content-write.d.cts +2 -2
- package/dist/content-write.d.ts +2 -2
- package/dist/content-write.js +21 -14
- package/dist/crypto/aes.cjs +76 -55
- package/dist/crypto/aes.js +76 -55
- package/dist/crypto/md5.cjs +345 -149
- package/dist/crypto/md5.js +345 -149
- package/dist/crypto/rc4.cjs +5 -4
- package/dist/crypto/rc4.js +5 -4
- package/dist/crypto/sha2.cjs +92 -43
- package/dist/crypto/sha2.js +92 -43
- package/dist/document.cjs +17 -11
- package/dist/document.d.cts +1 -1
- package/dist/document.d.ts +1 -1
- package/dist/document.js +17 -11
- package/dist/{embedded-font-Bnhh4juV.d.ts → embedded-font-ByD7ZiQS.d.ts} +1 -1
- package/dist/{embedded-font-CEf-zBCA.d.cts → embedded-font-DgVBedw6.d.cts} +1 -1
- package/dist/embedded-font-write.d.cts +2 -2
- package/dist/embedded-font-write.d.ts +2 -2
- package/dist/embedded-font.cjs +4 -2
- package/dist/embedded-font.d.cts +1 -1
- package/dist/embedded-font.d.ts +1 -1
- package/dist/embedded-font.js +4 -2
- package/dist/encoding.cjs +1 -1
- package/dist/encoding.js +1 -1
- package/dist/encrypt-write.cjs +25 -21
- package/dist/encrypt-write.d.cts +1 -1
- package/dist/encrypt-write.d.ts +1 -1
- package/dist/encrypt-write.js +25 -21
- package/dist/encrypt.cjs +43 -64
- package/dist/encrypt.d.cts +1 -1
- package/dist/encrypt.d.ts +1 -1
- package/dist/encrypt.js +43 -64
- package/dist/filters.cjs +46 -26
- package/dist/filters.d.cts +1 -1
- package/dist/filters.d.ts +1 -1
- package/dist/filters.js +46 -26
- package/dist/font-face.cjs +2 -1
- package/dist/font-face.js +2 -1
- package/dist/font-read.cjs +12 -6
- package/dist/font-read.d.cts +1 -1
- package/dist/font-read.d.ts +1 -1
- package/dist/font-read.js +12 -6
- package/dist/font-registry.d.cts +3 -3
- package/dist/font-registry.d.ts +3 -3
- package/dist/font-tables.cjs +55 -28
- package/dist/font-tables.js +55 -28
- package/dist/form.cjs +13 -8
- package/dist/form.d.cts +2 -2
- package/dist/form.d.ts +2 -2
- package/dist/form.js +13 -8
- package/dist/gdef-table.cjs +6 -3
- package/dist/gdef-table.js +6 -3
- package/dist/{glyf-contours-C0epBNqP.d.ts → glyf-contours-B1PsI9oA.d.ts} +1 -1
- package/dist/{glyf-contours-BRpvd0rt.d.cts → glyf-contours-NHBpgks-.d.cts} +1 -1
- package/dist/glyf-contours.cjs +3 -1
- package/dist/glyf-contours.d.cts +1 -1
- package/dist/glyf-contours.d.ts +1 -1
- package/dist/glyf-contours.js +3 -1
- package/dist/glyf.cjs +22 -11
- package/dist/glyf.js +22 -11
- package/dist/gpos-table.cjs +37 -19
- package/dist/gpos-table.js +37 -19
- package/dist/gsub-table.cjs +40 -25
- package/dist/gsub-table.js +40 -25
- package/dist/hmtx-table.cjs +5 -3
- package/dist/hmtx-table.js +5 -3
- package/dist/image/ccitt-encode.cjs +8 -5
- package/dist/image/ccitt-encode.js +8 -5
- package/dist/image/ccitt.cjs +801 -209
- package/dist/image/ccitt.js +801 -209
- package/dist/image/jbig2-arith.cjs +340 -306
- package/dist/image/jbig2-arith.js +340 -306
- package/dist/image/jbig2-bitmap.cjs +8 -5
- package/dist/image/jbig2-bitmap.js +8 -5
- package/dist/image/jbig2-generic.cjs +240 -69
- package/dist/image/jbig2-generic.js +240 -69
- package/dist/image/jbig2-text.cjs +4 -2
- package/dist/image/jbig2-text.js +4 -2
- package/dist/image/jbig2.cjs +69 -31
- package/dist/image/jbig2.js +69 -31
- package/dist/image/jp2-boxes.cjs +52 -27
- package/dist/image/jp2-boxes.js +52 -27
- package/dist/image/jpeg-info.cjs +29 -24
- package/dist/image/jpeg-info.js +29 -24
- package/dist/image/jpeg2000-codestream.cjs +61 -32
- package/dist/image/jpeg2000-codestream.js +61 -32
- package/dist/image/jpeg2000-dwt.cjs +2 -1
- package/dist/image/jpeg2000-dwt.js +2 -1
- package/dist/image/jpeg2000-t1.cjs +21 -11
- package/dist/image/jpeg2000-t1.js +21 -11
- package/dist/image/jpeg2000-t2.cjs +12 -5
- package/dist/image/jpeg2000-t2.js +12 -5
- package/dist/image/jpeg2000-tagtree.cjs +8 -4
- package/dist/image/jpeg2000-tagtree.js +8 -4
- package/dist/image/jpeg2000.cjs +11 -6
- package/dist/image/jpeg2000.js +11 -6
- package/dist/image/png-decode.cjs +62 -39
- package/dist/image/png-decode.d.cts +3 -2
- package/dist/image/png-decode.d.ts +3 -2
- package/dist/image/png-decode.js +62 -39
- package/dist/image/png-filter.cjs +23 -15
- package/dist/image/png-filter.js +23 -15
- package/dist/images-read.cjs +41 -36
- package/dist/images-read.d.cts +2 -2
- package/dist/images-read.d.ts +2 -2
- package/dist/images-read.js +41 -36
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interpret.cjs +68 -40
- package/dist/interpret.d.cts +1 -1
- package/dist/interpret.d.ts +1 -1
- package/dist/interpret.js +68 -40
- package/dist/lexer.cjs +86 -51
- package/dist/lexer.js +86 -51
- package/dist/math-content-write.cjs +9 -5
- package/dist/math-content-write.js +9 -5
- package/dist/math-font-write.cjs +2 -1
- package/dist/math-font-write.d.cts +1 -1
- package/dist/math-font-write.d.ts +1 -1
- package/dist/math-font-write.js +2 -1
- package/dist/math-font.cjs +16 -7
- package/dist/math-font.js +16 -7
- package/dist/math-table.cjs +25 -13
- package/dist/math-table.js +25 -13
- package/dist/matrix.cjs +3 -2
- package/dist/matrix.js +3 -2
- package/dist/measure.cjs +1 -1
- package/dist/measure.js +1 -1
- package/dist/names.cjs +7 -7
- package/dist/names.d.cts +2 -2
- package/dist/names.d.ts +2 -2
- package/dist/names.js +7 -7
- package/dist/navigation.cjs +16 -12
- package/dist/navigation.d.cts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.js +16 -12
- package/dist/{objects-B7HdMeWS.d.cts → objects-e2RS3-yT.d.cts} +3 -3
- package/dist/{objects-B7HdMeWS.d.ts → objects-e2RS3-yT.d.ts} +3 -3
- package/dist/objects.d.cts +1 -1
- package/dist/objects.d.ts +1 -1
- package/dist/optional-content.d.cts +2 -2
- package/dist/optional-content.d.ts +2 -2
- package/dist/ot-layout-common.cjs +22 -15
- package/dist/ot-layout-common.js +22 -15
- package/dist/parse.cjs +7 -5
- package/dist/parse.d.cts +1 -1
- package/dist/parse.d.ts +1 -1
- package/dist/parse.js +7 -5
- package/dist/pdf-text.cjs +5 -2
- package/dist/pdf-text.js +5 -2
- package/dist/predictors.cjs +14 -9
- package/dist/predictors.d.cts +1 -1
- package/dist/predictors.d.ts +1 -1
- package/dist/predictors.js +14 -9
- package/dist/raster.cjs +30 -19
- package/dist/raster.d.cts +8 -8
- package/dist/raster.d.ts +8 -8
- package/dist/raster.js +30 -19
- package/dist/read.cjs +29 -16
- package/dist/read.js +29 -16
- package/dist/serialize.cjs +6 -2
- package/dist/serialize.d.cts +1 -1
- package/dist/serialize.d.ts +1 -1
- package/dist/serialize.js +6 -2
- package/dist/sfnt-subset.cjs +25 -13
- package/dist/sfnt-subset.d.cts +1 -1
- package/dist/sfnt-subset.d.ts +1 -1
- package/dist/sfnt-subset.js +25 -13
- package/dist/sfnt.cjs +20 -10
- package/dist/sfnt.js +20 -10
- package/dist/structure.d.cts +2 -2
- package/dist/structure.d.ts +2 -2
- package/dist/text-group.cjs +0 -1
- package/dist/text-group.js +0 -1
- package/dist/text-layout.d.cts +1 -1
- package/dist/text-layout.d.ts +1 -1
- package/dist/tounicode.cjs +4 -2
- package/dist/tounicode.d.cts +1 -1
- package/dist/tounicode.d.ts +1 -1
- package/dist/tounicode.js +4 -2
- package/dist/winansi.cjs +1 -1
- package/dist/winansi.js +1 -1
- package/dist/write.cjs +20 -12
- package/dist/write.d.cts +1 -1
- package/dist/write.d.ts +1 -1
- package/dist/write.js +20 -12
- package/dist/xref.cjs +5 -2
- package/dist/xref.d.cts +1 -1
- package/dist/xref.d.ts +1 -1
- package/dist/xref.js +5 -2
- package/package.json +1 -1
package/dist/matrix.js
CHANGED
|
@@ -47,8 +47,9 @@ function scaleMatrix(sx, sy) {
|
|
|
47
47
|
];
|
|
48
48
|
}
|
|
49
49
|
const BEZIER_KAPPA = .5522847498;
|
|
50
|
+
const DEGREES_PER_HALF_TURN = 180;
|
|
50
51
|
function rotationMatrix(degrees) {
|
|
51
|
-
const radians = degrees * Math.PI /
|
|
52
|
+
const radians = degrees * Math.PI / DEGREES_PER_HALF_TURN;
|
|
52
53
|
const cos = Math.cos(radians);
|
|
53
54
|
const sin = Math.sin(radians);
|
|
54
55
|
return [
|
|
@@ -67,7 +68,7 @@ function matrixScaleY(m) {
|
|
|
67
68
|
return Math.hypot(m[2], m[3]);
|
|
68
69
|
}
|
|
69
70
|
function matrixRotationDegrees(m) {
|
|
70
|
-
return Math.atan2(m[1], m[0]) *
|
|
71
|
+
return Math.atan2(m[1], m[0]) * DEGREES_PER_HALF_TURN / Math.PI;
|
|
71
72
|
}
|
|
72
73
|
function rotatePointAboutCenter(point, center, degrees) {
|
|
73
74
|
const relative = {
|
package/dist/measure.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_afm_widths = require("./afm-widths-
|
|
2
|
+
const require_afm_widths = require("./afm-widths-BHD2HZIL.cjs");
|
|
3
3
|
const require_embedded_font = require("./embedded-font.cjs");
|
|
4
4
|
const require_font_registry = require("./font-registry.cjs");
|
|
5
5
|
//#region src/measure.ts
|
package/dist/measure.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as encodeForShow, t as STANDARD_METRICS } from "./afm-widths-
|
|
1
|
+
import { h as encodeForShow, t as STANDARD_METRICS } from "./afm-widths-B_IGbGky.js";
|
|
2
2
|
import { encodeForShowEmbedded } from "./embedded-font.js";
|
|
3
3
|
import { resolveFaceWithRegistry } from "./font-registry.js";
|
|
4
4
|
//#region src/measure.ts
|
package/dist/names.cjs
CHANGED
|
@@ -3,11 +3,9 @@ const require_objects = require("./objects.cjs");
|
|
|
3
3
|
const require_pdf_text = require("./pdf-text.cjs");
|
|
4
4
|
//#region src/names.ts
|
|
5
5
|
function walkNameTree(root, resolver, sink) {
|
|
6
|
-
|
|
7
|
-
collectNameTreeEntries(root, resolver, sink, entries, /* @__PURE__ */ new Set());
|
|
8
|
-
return entries;
|
|
6
|
+
return collectNameTreeEntries(root, resolver, sink, /* @__PURE__ */ new Set());
|
|
9
7
|
}
|
|
10
|
-
function collectNameTreeEntries(node, resolver, sink,
|
|
8
|
+
function collectNameTreeEntries(node, resolver, sink, visited) {
|
|
11
9
|
const dict = require_objects.asDict(resolver.resolve(node));
|
|
12
10
|
if (dict === void 0) {
|
|
13
11
|
if (node !== void 0) sink({
|
|
@@ -15,7 +13,7 @@ function collectNameTreeEntries(node, resolver, sink, entries, visited) {
|
|
|
15
13
|
severity: "warning",
|
|
16
14
|
message: "a name tree node did not resolve to a dictionary; skipping it"
|
|
17
15
|
});
|
|
18
|
-
return;
|
|
16
|
+
return [];
|
|
19
17
|
}
|
|
20
18
|
if (visited.has(dict)) {
|
|
21
19
|
sink({
|
|
@@ -23,9 +21,10 @@ function collectNameTreeEntries(node, resolver, sink, entries, visited) {
|
|
|
23
21
|
severity: "warning",
|
|
24
22
|
message: "the name tree contains a cycle; stopping descent at the repeated node"
|
|
25
23
|
});
|
|
26
|
-
return;
|
|
24
|
+
return [];
|
|
27
25
|
}
|
|
28
26
|
visited.add(dict);
|
|
27
|
+
const entries = [];
|
|
29
28
|
const names = require_objects.asArray(require_objects.dictGet(dict, "Names"));
|
|
30
29
|
if (names !== void 0) for (let i = 0; i + 1 < names.length; i += 2) {
|
|
31
30
|
const key = names[i];
|
|
@@ -35,7 +34,8 @@ function collectNameTreeEntries(node, resolver, sink, entries, visited) {
|
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
const kids = require_objects.asArray(require_objects.dictGet(dict, "Kids"));
|
|
38
|
-
if (kids !== void 0) for (const kid of kids) collectNameTreeEntries(kid, resolver, sink,
|
|
37
|
+
if (kids !== void 0) for (const kid of kids) for (const entry of collectNameTreeEntries(kid, resolver, sink, visited)) entries.push(entry);
|
|
38
|
+
return entries;
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
41
|
exports.walkNameTree = walkNameTree;
|
package/dist/names.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PdfDiagnosticSink } from "./diagnostics.cjs";
|
|
2
|
-
import { r as PdfObject } from "./objects-
|
|
2
|
+
import { r as PdfObject } from "./objects-e2RS3-yT.cjs";
|
|
3
3
|
import { PdfObjectResolver } from "./interpret.cjs";
|
|
4
4
|
//#region src/names.d.ts
|
|
5
5
|
interface NameTreeEntry {
|
|
6
6
|
readonly name: string;
|
|
7
7
|
readonly value: PdfObject;
|
|
8
8
|
}
|
|
9
|
-
declare function walkNameTree(root: PdfObject | undefined, resolver: PdfObjectResolver
|
|
9
|
+
declare function walkNameTree(root: PdfObject | undefined, resolver: Readonly<PdfObjectResolver>, sink: PdfDiagnosticSink): NameTreeEntry[];
|
|
10
10
|
//#endregion
|
|
11
11
|
export { NameTreeEntry, walkNameTree };
|
package/dist/names.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PdfDiagnosticSink } from "./diagnostics.js";
|
|
2
|
-
import { r as PdfObject } from "./objects-
|
|
2
|
+
import { r as PdfObject } from "./objects-e2RS3-yT.js";
|
|
3
3
|
import { PdfObjectResolver } from "./interpret.js";
|
|
4
4
|
//#region src/names.d.ts
|
|
5
5
|
interface NameTreeEntry {
|
|
6
6
|
readonly name: string;
|
|
7
7
|
readonly value: PdfObject;
|
|
8
8
|
}
|
|
9
|
-
declare function walkNameTree(root: PdfObject | undefined, resolver: PdfObjectResolver
|
|
9
|
+
declare function walkNameTree(root: PdfObject | undefined, resolver: Readonly<PdfObjectResolver>, sink: PdfDiagnosticSink): NameTreeEntry[];
|
|
10
10
|
//#endregion
|
|
11
11
|
export { NameTreeEntry, walkNameTree };
|
package/dist/names.js
CHANGED
|
@@ -2,11 +2,9 @@ import { asArray, asDict, dictGet } from "./objects.js";
|
|
|
2
2
|
import { decodePdfString } from "./pdf-text.js";
|
|
3
3
|
//#region src/names.ts
|
|
4
4
|
function walkNameTree(root, resolver, sink) {
|
|
5
|
-
|
|
6
|
-
collectNameTreeEntries(root, resolver, sink, entries, /* @__PURE__ */ new Set());
|
|
7
|
-
return entries;
|
|
5
|
+
return collectNameTreeEntries(root, resolver, sink, /* @__PURE__ */ new Set());
|
|
8
6
|
}
|
|
9
|
-
function collectNameTreeEntries(node, resolver, sink,
|
|
7
|
+
function collectNameTreeEntries(node, resolver, sink, visited) {
|
|
10
8
|
const dict = asDict(resolver.resolve(node));
|
|
11
9
|
if (dict === void 0) {
|
|
12
10
|
if (node !== void 0) sink({
|
|
@@ -14,7 +12,7 @@ function collectNameTreeEntries(node, resolver, sink, entries, visited) {
|
|
|
14
12
|
severity: "warning",
|
|
15
13
|
message: "a name tree node did not resolve to a dictionary; skipping it"
|
|
16
14
|
});
|
|
17
|
-
return;
|
|
15
|
+
return [];
|
|
18
16
|
}
|
|
19
17
|
if (visited.has(dict)) {
|
|
20
18
|
sink({
|
|
@@ -22,9 +20,10 @@ function collectNameTreeEntries(node, resolver, sink, entries, visited) {
|
|
|
22
20
|
severity: "warning",
|
|
23
21
|
message: "the name tree contains a cycle; stopping descent at the repeated node"
|
|
24
22
|
});
|
|
25
|
-
return;
|
|
23
|
+
return [];
|
|
26
24
|
}
|
|
27
25
|
visited.add(dict);
|
|
26
|
+
const entries = [];
|
|
28
27
|
const names = asArray(dictGet(dict, "Names"));
|
|
29
28
|
if (names !== void 0) for (let i = 0; i + 1 < names.length; i += 2) {
|
|
30
29
|
const key = names[i];
|
|
@@ -34,7 +33,8 @@ function collectNameTreeEntries(node, resolver, sink, entries, visited) {
|
|
|
34
33
|
});
|
|
35
34
|
}
|
|
36
35
|
const kids = asArray(dictGet(dict, "Kids"));
|
|
37
|
-
if (kids !== void 0) for (const kid of kids) collectNameTreeEntries(kid, resolver, sink,
|
|
36
|
+
if (kids !== void 0) for (const kid of kids) for (const entry of collectNameTreeEntries(kid, resolver, sink, visited)) entries.push(entry);
|
|
37
|
+
return entries;
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
40
|
export { walkNameTree };
|
package/dist/navigation.cjs
CHANGED
|
@@ -6,6 +6,11 @@ const require_names = require("./names.cjs");
|
|
|
6
6
|
function coordinateAt(arr, index) {
|
|
7
7
|
return require_objects.asNumber(arr[index]);
|
|
8
8
|
}
|
|
9
|
+
const DEST_XYZ_TOP_INDEX = 3;
|
|
10
|
+
const DEST_XYZ_ZOOM_INDEX = 4;
|
|
11
|
+
const DEST_FITR_BOTTOM_INDEX = 3;
|
|
12
|
+
const DEST_FITR_RIGHT_INDEX = 4;
|
|
13
|
+
const DEST_FITR_TOP_INDEX = 5;
|
|
9
14
|
function parseDestination(value, resolver, pageIndex, sink) {
|
|
10
15
|
const arr = require_objects.asArray(resolver.resolve(value));
|
|
11
16
|
if (arr === void 0 || arr.length < 2) {
|
|
@@ -33,8 +38,8 @@ function parseDestination(value, resolver, pageIndex, sink) {
|
|
|
33
38
|
kind: "xyz",
|
|
34
39
|
...optionalCoords(arr, [
|
|
35
40
|
["leftPt", 2],
|
|
36
|
-
["topPt",
|
|
37
|
-
["zoom",
|
|
41
|
+
["topPt", DEST_XYZ_TOP_INDEX],
|
|
42
|
+
["zoom", DEST_XYZ_ZOOM_INDEX]
|
|
38
43
|
])
|
|
39
44
|
}
|
|
40
45
|
};
|
|
@@ -62,9 +67,9 @@ function parseDestination(value, resolver, pageIndex, sink) {
|
|
|
62
67
|
kind: "fitR",
|
|
63
68
|
...optionalCoords(arr, [
|
|
64
69
|
["leftPt", 2],
|
|
65
|
-
["bottomPt",
|
|
66
|
-
["rightPt",
|
|
67
|
-
["topPt",
|
|
70
|
+
["bottomPt", DEST_FITR_BOTTOM_INDEX],
|
|
71
|
+
["rightPt", DEST_FITR_RIGHT_INDEX],
|
|
72
|
+
["topPt", DEST_FITR_TOP_INDEX]
|
|
68
73
|
])
|
|
69
74
|
}
|
|
70
75
|
};
|
|
@@ -161,11 +166,10 @@ function readOutline(catalog, registry, resolver, sink) {
|
|
|
161
166
|
const root = resolver.resolveDict(require_objects.dictGet(catalog, "Outlines"));
|
|
162
167
|
const first = root === void 0 ? void 0 : resolver.resolveDict(require_objects.dictGet(root, "First"));
|
|
163
168
|
if (first === void 0) return [];
|
|
164
|
-
|
|
165
|
-
walkOutlineSiblings(first, items, registry, resolver, sink, /* @__PURE__ */ new Set());
|
|
166
|
-
return items;
|
|
169
|
+
return walkOutlineSiblings(first, registry, resolver, sink, /* @__PURE__ */ new Set());
|
|
167
170
|
}
|
|
168
|
-
function walkOutlineSiblings(node,
|
|
171
|
+
function walkOutlineSiblings(node, registry, resolver, sink, visited) {
|
|
172
|
+
const out = [];
|
|
169
173
|
let current = node;
|
|
170
174
|
while (current !== void 0) {
|
|
171
175
|
if (visited.has(current)) {
|
|
@@ -174,13 +178,12 @@ function walkOutlineSiblings(node, out, registry, resolver, sink, visited) {
|
|
|
174
178
|
severity: "warning",
|
|
175
179
|
message: "the outline contains a cycle; stopping the sibling chain at the repeated item"
|
|
176
180
|
});
|
|
177
|
-
return;
|
|
181
|
+
return out;
|
|
178
182
|
}
|
|
179
183
|
visited.add(current);
|
|
180
184
|
const titleObj = require_objects.dictGet(current, "Title");
|
|
181
|
-
const children = [];
|
|
182
185
|
const childFirst = resolver.resolveDict(require_objects.dictGet(current, "First"));
|
|
183
|
-
|
|
186
|
+
const children = childFirst === void 0 ? [] : walkOutlineSiblings(childFirst, registry, resolver, sink, visited);
|
|
184
187
|
const destination = internOutlineDestination(current, registry, resolver);
|
|
185
188
|
out.push({
|
|
186
189
|
title: titleObj?.kind === "string" ? require_pdf_text.decodePdfString(titleObj.bytes) : "",
|
|
@@ -189,6 +192,7 @@ function walkOutlineSiblings(node, out, registry, resolver, sink, visited) {
|
|
|
189
192
|
});
|
|
190
193
|
current = resolver.resolveDict(require_objects.dictGet(current, "Next"));
|
|
191
194
|
}
|
|
195
|
+
return out;
|
|
192
196
|
}
|
|
193
197
|
function internOutlineDestination(node, registry, resolver) {
|
|
194
198
|
const dest = require_objects.dictGet(node, "Dest");
|
package/dist/navigation.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PdfDiagnosticSink } from "./diagnostics.cjs";
|
|
2
|
-
import { n as PdfDict, r as PdfObject } from "./objects-
|
|
2
|
+
import { n as PdfDict, r as PdfObject } from "./objects-e2RS3-yT.cjs";
|
|
3
3
|
import { PdfObjectResolver } from "./interpret.cjs";
|
|
4
4
|
import { LayoutDestination, LayoutDestinationTarget, LayoutOutlineItem } from "./layout.cjs";
|
|
5
5
|
//#region src/navigation.d.ts
|
|
6
6
|
type PageIndexLookup = (obj: PdfObject | undefined) => number | undefined;
|
|
7
|
-
declare function parseDestination(value: PdfObject | undefined, resolver: PdfObjectResolver
|
|
7
|
+
declare function parseDestination(value: PdfObject | undefined, resolver: Readonly<PdfObjectResolver>, pageIndex: PageIndexLookup, sink: PdfDiagnosticSink): {
|
|
8
8
|
pageIndex: number;
|
|
9
9
|
target: LayoutDestinationTarget;
|
|
10
10
|
} | undefined;
|
|
@@ -12,7 +12,7 @@ interface DestinationRegistry {
|
|
|
12
12
|
readonly entries: readonly LayoutDestination[];
|
|
13
13
|
intern: (obj: PdfObject | undefined) => string | undefined;
|
|
14
14
|
}
|
|
15
|
-
declare function createDestinationRegistry(catalog: PdfDict, resolver: PdfObjectResolver
|
|
16
|
-
declare function readOutline(catalog: PdfDict, registry: DestinationRegistry, resolver: PdfObjectResolver
|
|
15
|
+
declare function createDestinationRegistry(catalog: PdfDict, resolver: Readonly<PdfObjectResolver>, pageIndex: PageIndexLookup, sink: PdfDiagnosticSink): DestinationRegistry;
|
|
16
|
+
declare function readOutline(catalog: PdfDict, registry: DestinationRegistry, resolver: Readonly<PdfObjectResolver>, sink: PdfDiagnosticSink): LayoutOutlineItem[];
|
|
17
17
|
//#endregion
|
|
18
18
|
export { DestinationRegistry, PageIndexLookup, createDestinationRegistry, parseDestination, readOutline };
|
package/dist/navigation.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PdfDiagnosticSink } from "./diagnostics.js";
|
|
2
|
-
import { n as PdfDict, r as PdfObject } from "./objects-
|
|
2
|
+
import { n as PdfDict, r as PdfObject } from "./objects-e2RS3-yT.js";
|
|
3
3
|
import { PdfObjectResolver } from "./interpret.js";
|
|
4
4
|
import { LayoutDestination, LayoutDestinationTarget, LayoutOutlineItem } from "./layout.js";
|
|
5
5
|
//#region src/navigation.d.ts
|
|
6
6
|
type PageIndexLookup = (obj: PdfObject | undefined) => number | undefined;
|
|
7
|
-
declare function parseDestination(value: PdfObject | undefined, resolver: PdfObjectResolver
|
|
7
|
+
declare function parseDestination(value: PdfObject | undefined, resolver: Readonly<PdfObjectResolver>, pageIndex: PageIndexLookup, sink: PdfDiagnosticSink): {
|
|
8
8
|
pageIndex: number;
|
|
9
9
|
target: LayoutDestinationTarget;
|
|
10
10
|
} | undefined;
|
|
@@ -12,7 +12,7 @@ interface DestinationRegistry {
|
|
|
12
12
|
readonly entries: readonly LayoutDestination[];
|
|
13
13
|
intern: (obj: PdfObject | undefined) => string | undefined;
|
|
14
14
|
}
|
|
15
|
-
declare function createDestinationRegistry(catalog: PdfDict, resolver: PdfObjectResolver
|
|
16
|
-
declare function readOutline(catalog: PdfDict, registry: DestinationRegistry, resolver: PdfObjectResolver
|
|
15
|
+
declare function createDestinationRegistry(catalog: PdfDict, resolver: Readonly<PdfObjectResolver>, pageIndex: PageIndexLookup, sink: PdfDiagnosticSink): DestinationRegistry;
|
|
16
|
+
declare function readOutline(catalog: PdfDict, registry: DestinationRegistry, resolver: Readonly<PdfObjectResolver>, sink: PdfDiagnosticSink): LayoutOutlineItem[];
|
|
17
17
|
//#endregion
|
|
18
18
|
export { DestinationRegistry, PageIndexLookup, createDestinationRegistry, parseDestination, readOutline };
|
package/dist/navigation.js
CHANGED
|
@@ -5,6 +5,11 @@ import { walkNameTree } from "./names.js";
|
|
|
5
5
|
function coordinateAt(arr, index) {
|
|
6
6
|
return asNumber(arr[index]);
|
|
7
7
|
}
|
|
8
|
+
const DEST_XYZ_TOP_INDEX = 3;
|
|
9
|
+
const DEST_XYZ_ZOOM_INDEX = 4;
|
|
10
|
+
const DEST_FITR_BOTTOM_INDEX = 3;
|
|
11
|
+
const DEST_FITR_RIGHT_INDEX = 4;
|
|
12
|
+
const DEST_FITR_TOP_INDEX = 5;
|
|
8
13
|
function parseDestination(value, resolver, pageIndex, sink) {
|
|
9
14
|
const arr = asArray(resolver.resolve(value));
|
|
10
15
|
if (arr === void 0 || arr.length < 2) {
|
|
@@ -32,8 +37,8 @@ function parseDestination(value, resolver, pageIndex, sink) {
|
|
|
32
37
|
kind: "xyz",
|
|
33
38
|
...optionalCoords(arr, [
|
|
34
39
|
["leftPt", 2],
|
|
35
|
-
["topPt",
|
|
36
|
-
["zoom",
|
|
40
|
+
["topPt", DEST_XYZ_TOP_INDEX],
|
|
41
|
+
["zoom", DEST_XYZ_ZOOM_INDEX]
|
|
37
42
|
])
|
|
38
43
|
}
|
|
39
44
|
};
|
|
@@ -61,9 +66,9 @@ function parseDestination(value, resolver, pageIndex, sink) {
|
|
|
61
66
|
kind: "fitR",
|
|
62
67
|
...optionalCoords(arr, [
|
|
63
68
|
["leftPt", 2],
|
|
64
|
-
["bottomPt",
|
|
65
|
-
["rightPt",
|
|
66
|
-
["topPt",
|
|
69
|
+
["bottomPt", DEST_FITR_BOTTOM_INDEX],
|
|
70
|
+
["rightPt", DEST_FITR_RIGHT_INDEX],
|
|
71
|
+
["topPt", DEST_FITR_TOP_INDEX]
|
|
67
72
|
])
|
|
68
73
|
}
|
|
69
74
|
};
|
|
@@ -160,11 +165,10 @@ function readOutline(catalog, registry, resolver, sink) {
|
|
|
160
165
|
const root = resolver.resolveDict(dictGet(catalog, "Outlines"));
|
|
161
166
|
const first = root === void 0 ? void 0 : resolver.resolveDict(dictGet(root, "First"));
|
|
162
167
|
if (first === void 0) return [];
|
|
163
|
-
|
|
164
|
-
walkOutlineSiblings(first, items, registry, resolver, sink, /* @__PURE__ */ new Set());
|
|
165
|
-
return items;
|
|
168
|
+
return walkOutlineSiblings(first, registry, resolver, sink, /* @__PURE__ */ new Set());
|
|
166
169
|
}
|
|
167
|
-
function walkOutlineSiblings(node,
|
|
170
|
+
function walkOutlineSiblings(node, registry, resolver, sink, visited) {
|
|
171
|
+
const out = [];
|
|
168
172
|
let current = node;
|
|
169
173
|
while (current !== void 0) {
|
|
170
174
|
if (visited.has(current)) {
|
|
@@ -173,13 +177,12 @@ function walkOutlineSiblings(node, out, registry, resolver, sink, visited) {
|
|
|
173
177
|
severity: "warning",
|
|
174
178
|
message: "the outline contains a cycle; stopping the sibling chain at the repeated item"
|
|
175
179
|
});
|
|
176
|
-
return;
|
|
180
|
+
return out;
|
|
177
181
|
}
|
|
178
182
|
visited.add(current);
|
|
179
183
|
const titleObj = dictGet(current, "Title");
|
|
180
|
-
const children = [];
|
|
181
184
|
const childFirst = resolver.resolveDict(dictGet(current, "First"));
|
|
182
|
-
|
|
185
|
+
const children = childFirst === void 0 ? [] : walkOutlineSiblings(childFirst, registry, resolver, sink, visited);
|
|
183
186
|
const destination = internOutlineDestination(current, registry, resolver);
|
|
184
187
|
out.push({
|
|
185
188
|
title: titleObj?.kind === "string" ? decodePdfString(titleObj.bytes) : "",
|
|
@@ -188,6 +191,7 @@ function walkOutlineSiblings(node, out, registry, resolver, sink, visited) {
|
|
|
188
191
|
});
|
|
189
192
|
current = resolver.resolveDict(dictGet(current, "Next"));
|
|
190
193
|
}
|
|
194
|
+
return out;
|
|
191
195
|
}
|
|
192
196
|
function internOutlineDestination(node, registry, resolver) {
|
|
193
197
|
const dest = dictGet(node, "Dest");
|
|
@@ -16,7 +16,7 @@ type PdfObject = {
|
|
|
16
16
|
hex: boolean;
|
|
17
17
|
} | {
|
|
18
18
|
kind: "array";
|
|
19
|
-
items: PdfObject[];
|
|
19
|
+
items: readonly PdfObject[];
|
|
20
20
|
} | {
|
|
21
21
|
kind: "dict";
|
|
22
22
|
entries: Map<string, PdfObject>;
|
|
@@ -44,7 +44,7 @@ declare function pdfNum(value: number): PdfObject;
|
|
|
44
44
|
declare function pdfName(name: string): PdfObject;
|
|
45
45
|
declare function pdfHexString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
|
|
46
46
|
declare function pdfLiteralString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
|
|
47
|
-
declare function pdfArray(items: PdfObject[]): PdfObject;
|
|
47
|
+
declare function pdfArray(items: readonly PdfObject[]): PdfObject;
|
|
48
48
|
declare function pdfDict(entries: Record<string, PdfObject> | Map<string, PdfObject>): PdfDict;
|
|
49
49
|
declare function pdfStream(dict: PdfDict, raw: Uint8Array<ArrayBuffer>): PdfObject;
|
|
50
50
|
declare function pdfRef(num: number, gen: number): PdfObject;
|
|
@@ -52,7 +52,7 @@ declare function isName(obj: PdfObject | undefined, name: string): boolean;
|
|
|
52
52
|
declare function asNumber(obj: PdfObject | undefined): number | undefined;
|
|
53
53
|
declare function asName(obj: PdfObject | undefined): string | undefined;
|
|
54
54
|
declare function asBool(obj: PdfObject | undefined): boolean | undefined;
|
|
55
|
-
declare function asArray(obj: PdfObject | undefined): PdfObject[] | undefined;
|
|
55
|
+
declare function asArray(obj: PdfObject | undefined): readonly PdfObject[] | undefined;
|
|
56
56
|
declare function asDict(obj: PdfObject | undefined): PdfDict | undefined;
|
|
57
57
|
declare function dictGet(dict: PdfDict, key: string): PdfObject | undefined;
|
|
58
58
|
//#endregion
|
|
@@ -16,7 +16,7 @@ type PdfObject = {
|
|
|
16
16
|
hex: boolean;
|
|
17
17
|
} | {
|
|
18
18
|
kind: "array";
|
|
19
|
-
items: PdfObject[];
|
|
19
|
+
items: readonly PdfObject[];
|
|
20
20
|
} | {
|
|
21
21
|
kind: "dict";
|
|
22
22
|
entries: Map<string, PdfObject>;
|
|
@@ -44,7 +44,7 @@ declare function pdfNum(value: number): PdfObject;
|
|
|
44
44
|
declare function pdfName(name: string): PdfObject;
|
|
45
45
|
declare function pdfHexString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
|
|
46
46
|
declare function pdfLiteralString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
|
|
47
|
-
declare function pdfArray(items: PdfObject[]): PdfObject;
|
|
47
|
+
declare function pdfArray(items: readonly PdfObject[]): PdfObject;
|
|
48
48
|
declare function pdfDict(entries: Record<string, PdfObject> | Map<string, PdfObject>): PdfDict;
|
|
49
49
|
declare function pdfStream(dict: PdfDict, raw: Uint8Array<ArrayBuffer>): PdfObject;
|
|
50
50
|
declare function pdfRef(num: number, gen: number): PdfObject;
|
|
@@ -52,7 +52,7 @@ declare function isName(obj: PdfObject | undefined, name: string): boolean;
|
|
|
52
52
|
declare function asNumber(obj: PdfObject | undefined): number | undefined;
|
|
53
53
|
declare function asName(obj: PdfObject | undefined): string | undefined;
|
|
54
54
|
declare function asBool(obj: PdfObject | undefined): boolean | undefined;
|
|
55
|
-
declare function asArray(obj: PdfObject | undefined): PdfObject[] | undefined;
|
|
55
|
+
declare function asArray(obj: PdfObject | undefined): readonly PdfObject[] | undefined;
|
|
56
56
|
declare function asDict(obj: PdfObject | undefined): PdfDict | undefined;
|
|
57
57
|
declare function dictGet(dict: PdfDict, key: string): PdfObject | undefined;
|
|
58
58
|
//#endregion
|
package/dist/objects.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as pdfName, a as asArray, b as pdfRef, c as asName, d as isName, f as pdfArray, g as pdfLiteralString, h as pdfHexString, i as PdfStream, l as asNumber, m as pdfDict, n as PdfDict, o as asBool, p as pdfBool, r as PdfObject, s as asDict, t as PdfArray, u as dictGet, v as pdfNull, x as pdfStream, y as pdfNum } from "./objects-
|
|
1
|
+
import { _ as pdfName, a as asArray, b as pdfRef, c as asName, d as isName, f as pdfArray, g as pdfLiteralString, h as pdfHexString, i as PdfStream, l as asNumber, m as pdfDict, n as PdfDict, o as asBool, p as pdfBool, r as PdfObject, s as asDict, t as PdfArray, u as dictGet, v as pdfNull, x as pdfStream, y as pdfNum } from "./objects-e2RS3-yT.cjs";
|
|
2
2
|
export { PdfArray, PdfDict, PdfObject, PdfStream, asArray, asBool, asDict, asName, asNumber, dictGet, isName, pdfArray, pdfBool, pdfDict, pdfHexString, pdfLiteralString, pdfName, pdfNull, pdfNum, pdfRef, pdfStream };
|
package/dist/objects.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as pdfName, a as asArray, b as pdfRef, c as asName, d as isName, f as pdfArray, g as pdfLiteralString, h as pdfHexString, i as PdfStream, l as asNumber, m as pdfDict, n as PdfDict, o as asBool, p as pdfBool, r as PdfObject, s as asDict, t as PdfArray, u as dictGet, v as pdfNull, x as pdfStream, y as pdfNum } from "./objects-
|
|
1
|
+
import { _ as pdfName, a as asArray, b as pdfRef, c as asName, d as isName, f as pdfArray, g as pdfLiteralString, h as pdfHexString, i as PdfStream, l as asNumber, m as pdfDict, n as PdfDict, o as asBool, p as pdfBool, r as PdfObject, s as asDict, t as PdfArray, u as dictGet, v as pdfNull, x as pdfStream, y as pdfNum } from "./objects-e2RS3-yT.js";
|
|
2
2
|
export { PdfArray, PdfDict, PdfObject, PdfStream, asArray, asBool, asDict, asName, asNumber, dictGet, isName, pdfArray, pdfBool, pdfDict, pdfHexString, pdfLiteralString, pdfName, pdfNull, pdfNum, pdfRef, pdfStream };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PdfDiagnosticSink } from "./diagnostics.cjs";
|
|
2
|
-
import { n as PdfDict, r as PdfObject } from "./objects-
|
|
2
|
+
import { n as PdfDict, r as PdfObject } from "./objects-e2RS3-yT.cjs";
|
|
3
3
|
import { PdfObjectResolver } from "./interpret.cjs";
|
|
4
4
|
import { LayoutLayer } from "./layout.cjs";
|
|
5
5
|
//#region src/optional-content.d.ts
|
|
@@ -7,6 +7,6 @@ interface OptionalContentContext {
|
|
|
7
7
|
readonly layers: readonly LayoutLayer[];
|
|
8
8
|
readonly layerNameOf: (obj: PdfObject | undefined) => string | undefined;
|
|
9
9
|
}
|
|
10
|
-
declare function readOptionalContent(catalog: PdfDict, resolver: PdfObjectResolver
|
|
10
|
+
declare function readOptionalContent(catalog: PdfDict, resolver: Readonly<PdfObjectResolver>, sink: PdfDiagnosticSink): OptionalContentContext;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { OptionalContentContext, readOptionalContent };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PdfDiagnosticSink } from "./diagnostics.js";
|
|
2
|
-
import { n as PdfDict, r as PdfObject } from "./objects-
|
|
2
|
+
import { n as PdfDict, r as PdfObject } from "./objects-e2RS3-yT.js";
|
|
3
3
|
import { PdfObjectResolver } from "./interpret.js";
|
|
4
4
|
import { LayoutLayer } from "./layout.js";
|
|
5
5
|
//#region src/optional-content.d.ts
|
|
@@ -7,6 +7,6 @@ interface OptionalContentContext {
|
|
|
7
7
|
readonly layers: readonly LayoutLayer[];
|
|
8
8
|
readonly layerNameOf: (obj: PdfObject | undefined) => string | undefined;
|
|
9
9
|
}
|
|
10
|
-
declare function readOptionalContent(catalog: PdfDict, resolver: PdfObjectResolver
|
|
10
|
+
declare function readOptionalContent(catalog: PdfDict, resolver: Readonly<PdfObjectResolver>, sink: PdfDiagnosticSink): OptionalContentContext;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { OptionalContentContext, readOptionalContent };
|
|
@@ -12,23 +12,21 @@ function findRange(ranges, glyphId) {
|
|
|
12
12
|
else return range;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function placeGlyph(ranges, glyphId, value, valueStep) {
|
|
16
16
|
const previous = ranges[ranges.length - 1];
|
|
17
|
-
if (previous !== void 0 && glyphId === previous.endGlyphId + 1 && value === previous.value + (previous.endGlyphId - previous.startGlyphId + 1) * valueStep) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
ranges.push({
|
|
17
|
+
if (previous !== void 0 && glyphId === previous.endGlyphId + 1 && value === previous.value + (previous.endGlyphId - previous.startGlyphId + 1) * valueStep) return { extended: {
|
|
18
|
+
startGlyphId: previous.startGlyphId,
|
|
19
|
+
endGlyphId: glyphId,
|
|
20
|
+
value: previous.value
|
|
21
|
+
} };
|
|
22
|
+
return { fresh: {
|
|
26
23
|
startGlyphId: glyphId,
|
|
27
24
|
endGlyphId: glyphId,
|
|
28
25
|
value
|
|
29
|
-
}
|
|
26
|
+
} };
|
|
30
27
|
}
|
|
31
28
|
const RANGE_RECORD_SIZE = 6;
|
|
29
|
+
const RANGE_RECORD_VALUE_OFFSET = 4;
|
|
32
30
|
function parseRangeRecords(bytes, recordsOffset, recordCount) {
|
|
33
31
|
if (!require_sfnt.hasBytes(bytes, recordsOffset, recordCount * RANGE_RECORD_SIZE)) return;
|
|
34
32
|
const ranges = [];
|
|
@@ -40,7 +38,7 @@ function parseRangeRecords(bytes, recordsOffset, recordCount) {
|
|
|
40
38
|
ranges.push({
|
|
41
39
|
startGlyphId,
|
|
42
40
|
endGlyphId,
|
|
43
|
-
value: require_sfnt.u16(bytes, recordOffset +
|
|
41
|
+
value: require_sfnt.u16(bytes, recordOffset + RANGE_RECORD_VALUE_OFFSET)
|
|
44
42
|
});
|
|
45
43
|
}
|
|
46
44
|
ranges.sort((a, b) => a.startGlyphId - b.startGlyphId);
|
|
@@ -56,7 +54,11 @@ function parseCoverage(bytes, coverageOffset) {
|
|
|
56
54
|
const glyphArrayOffset = coverageOffset + COVERAGE_HEADER_SIZE;
|
|
57
55
|
if (!require_sfnt.hasBytes(bytes, glyphArrayOffset, count * 2)) return;
|
|
58
56
|
ranges = [];
|
|
59
|
-
for (let i = 0; i < count; i++)
|
|
57
|
+
for (let i = 0; i < count; i++) {
|
|
58
|
+
const placement = placeGlyph(ranges, require_sfnt.u16(bytes, glyphArrayOffset + i * 2), i, 1);
|
|
59
|
+
if (placement.extended !== void 0) ranges[ranges.length - 1] = placement.extended;
|
|
60
|
+
else ranges.push(placement.fresh);
|
|
61
|
+
}
|
|
60
62
|
ranges.sort((a, b) => a.startGlyphId - b.startGlyphId);
|
|
61
63
|
} else if (format === 2) ranges = parseRangeRecords(bytes, coverageOffset + COVERAGE_HEADER_SIZE, count);
|
|
62
64
|
if (ranges === void 0) return;
|
|
@@ -72,6 +74,7 @@ function parseCoverage(bytes, coverageOffset) {
|
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
76
|
const CLASS_DEF_FORMAT_1_HEADER_SIZE = 6;
|
|
77
|
+
const CLASS_DEF_FORMAT_1_GLYPH_COUNT_OFFSET = 4;
|
|
75
78
|
const CLASS_DEF_FORMAT_2_HEADER_SIZE = 4;
|
|
76
79
|
function parseClassDef(bytes, classDefOffset) {
|
|
77
80
|
if (!require_sfnt.hasBytes(bytes, classDefOffset, CLASS_DEF_FORMAT_2_HEADER_SIZE)) return;
|
|
@@ -80,11 +83,15 @@ function parseClassDef(bytes, classDefOffset) {
|
|
|
80
83
|
if (format === 1) {
|
|
81
84
|
if (!require_sfnt.hasBytes(bytes, classDefOffset, CLASS_DEF_FORMAT_1_HEADER_SIZE)) return;
|
|
82
85
|
const startGlyphId = require_sfnt.u16(bytes, classDefOffset + 2);
|
|
83
|
-
const glyphCount = require_sfnt.u16(bytes, classDefOffset +
|
|
86
|
+
const glyphCount = require_sfnt.u16(bytes, classDefOffset + CLASS_DEF_FORMAT_1_GLYPH_COUNT_OFFSET);
|
|
84
87
|
const classArrayOffset = classDefOffset + CLASS_DEF_FORMAT_1_HEADER_SIZE;
|
|
85
88
|
if (!require_sfnt.hasBytes(bytes, classArrayOffset, glyphCount * 2)) return;
|
|
86
89
|
ranges = [];
|
|
87
|
-
for (let i = 0; i < glyphCount; i++)
|
|
90
|
+
for (let i = 0; i < glyphCount; i++) {
|
|
91
|
+
const placement = placeGlyph(ranges, startGlyphId + i, require_sfnt.u16(bytes, classArrayOffset + i * 2), 0);
|
|
92
|
+
if (placement.extended !== void 0) ranges[ranges.length - 1] = placement.extended;
|
|
93
|
+
else ranges.push(placement.fresh);
|
|
94
|
+
}
|
|
88
95
|
} else if (format === 2) ranges = parseRangeRecords(bytes, classDefOffset + CLASS_DEF_FORMAT_2_HEADER_SIZE, require_sfnt.u16(bytes, classDefOffset + 2));
|
|
89
96
|
if (ranges === void 0) return;
|
|
90
97
|
const resolved = ranges;
|
package/dist/ot-layout-common.js
CHANGED
|
@@ -11,23 +11,21 @@ function findRange(ranges, glyphId) {
|
|
|
11
11
|
else return range;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function placeGlyph(ranges, glyphId, value, valueStep) {
|
|
15
15
|
const previous = ranges[ranges.length - 1];
|
|
16
|
-
if (previous !== void 0 && glyphId === previous.endGlyphId + 1 && value === previous.value + (previous.endGlyphId - previous.startGlyphId + 1) * valueStep) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
ranges.push({
|
|
16
|
+
if (previous !== void 0 && glyphId === previous.endGlyphId + 1 && value === previous.value + (previous.endGlyphId - previous.startGlyphId + 1) * valueStep) return { extended: {
|
|
17
|
+
startGlyphId: previous.startGlyphId,
|
|
18
|
+
endGlyphId: glyphId,
|
|
19
|
+
value: previous.value
|
|
20
|
+
} };
|
|
21
|
+
return { fresh: {
|
|
25
22
|
startGlyphId: glyphId,
|
|
26
23
|
endGlyphId: glyphId,
|
|
27
24
|
value
|
|
28
|
-
}
|
|
25
|
+
} };
|
|
29
26
|
}
|
|
30
27
|
const RANGE_RECORD_SIZE = 6;
|
|
28
|
+
const RANGE_RECORD_VALUE_OFFSET = 4;
|
|
31
29
|
function parseRangeRecords(bytes, recordsOffset, recordCount) {
|
|
32
30
|
if (!hasBytes(bytes, recordsOffset, recordCount * RANGE_RECORD_SIZE)) return;
|
|
33
31
|
const ranges = [];
|
|
@@ -39,7 +37,7 @@ function parseRangeRecords(bytes, recordsOffset, recordCount) {
|
|
|
39
37
|
ranges.push({
|
|
40
38
|
startGlyphId,
|
|
41
39
|
endGlyphId,
|
|
42
|
-
value: u16(bytes, recordOffset +
|
|
40
|
+
value: u16(bytes, recordOffset + RANGE_RECORD_VALUE_OFFSET)
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
43
|
ranges.sort((a, b) => a.startGlyphId - b.startGlyphId);
|
|
@@ -55,7 +53,11 @@ function parseCoverage(bytes, coverageOffset) {
|
|
|
55
53
|
const glyphArrayOffset = coverageOffset + COVERAGE_HEADER_SIZE;
|
|
56
54
|
if (!hasBytes(bytes, glyphArrayOffset, count * 2)) return;
|
|
57
55
|
ranges = [];
|
|
58
|
-
for (let i = 0; i < count; i++)
|
|
56
|
+
for (let i = 0; i < count; i++) {
|
|
57
|
+
const placement = placeGlyph(ranges, u16(bytes, glyphArrayOffset + i * 2), i, 1);
|
|
58
|
+
if (placement.extended !== void 0) ranges[ranges.length - 1] = placement.extended;
|
|
59
|
+
else ranges.push(placement.fresh);
|
|
60
|
+
}
|
|
59
61
|
ranges.sort((a, b) => a.startGlyphId - b.startGlyphId);
|
|
60
62
|
} else if (format === 2) ranges = parseRangeRecords(bytes, coverageOffset + COVERAGE_HEADER_SIZE, count);
|
|
61
63
|
if (ranges === void 0) return;
|
|
@@ -71,6 +73,7 @@ function parseCoverage(bytes, coverageOffset) {
|
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
75
|
const CLASS_DEF_FORMAT_1_HEADER_SIZE = 6;
|
|
76
|
+
const CLASS_DEF_FORMAT_1_GLYPH_COUNT_OFFSET = 4;
|
|
74
77
|
const CLASS_DEF_FORMAT_2_HEADER_SIZE = 4;
|
|
75
78
|
function parseClassDef(bytes, classDefOffset) {
|
|
76
79
|
if (!hasBytes(bytes, classDefOffset, CLASS_DEF_FORMAT_2_HEADER_SIZE)) return;
|
|
@@ -79,11 +82,15 @@ function parseClassDef(bytes, classDefOffset) {
|
|
|
79
82
|
if (format === 1) {
|
|
80
83
|
if (!hasBytes(bytes, classDefOffset, CLASS_DEF_FORMAT_1_HEADER_SIZE)) return;
|
|
81
84
|
const startGlyphId = u16(bytes, classDefOffset + 2);
|
|
82
|
-
const glyphCount = u16(bytes, classDefOffset +
|
|
85
|
+
const glyphCount = u16(bytes, classDefOffset + CLASS_DEF_FORMAT_1_GLYPH_COUNT_OFFSET);
|
|
83
86
|
const classArrayOffset = classDefOffset + CLASS_DEF_FORMAT_1_HEADER_SIZE;
|
|
84
87
|
if (!hasBytes(bytes, classArrayOffset, glyphCount * 2)) return;
|
|
85
88
|
ranges = [];
|
|
86
|
-
for (let i = 0; i < glyphCount; i++)
|
|
89
|
+
for (let i = 0; i < glyphCount; i++) {
|
|
90
|
+
const placement = placeGlyph(ranges, startGlyphId + i, u16(bytes, classArrayOffset + i * 2), 0);
|
|
91
|
+
if (placement.extended !== void 0) ranges[ranges.length - 1] = placement.extended;
|
|
92
|
+
else ranges.push(placement.fresh);
|
|
93
|
+
}
|
|
87
94
|
} else if (format === 2) ranges = parseRangeRecords(bytes, classDefOffset + CLASS_DEF_FORMAT_2_HEADER_SIZE, u16(bytes, classDefOffset + 2));
|
|
88
95
|
if (ranges === void 0) return;
|
|
89
96
|
const resolved = ranges;
|
package/dist/parse.cjs
CHANGED
|
@@ -110,10 +110,12 @@ function parseDictOrStreamBody(reader, sink) {
|
|
|
110
110
|
reader.reset(afterDictMark);
|
|
111
111
|
return dict;
|
|
112
112
|
}
|
|
113
|
+
const CARRIAGE_RETURN = 13;
|
|
114
|
+
const LINE_FEED = 10;
|
|
113
115
|
function skipStreamDataStart(reader, sink) {
|
|
114
|
-
if (reader.peek() ===
|
|
116
|
+
if (reader.peek() === CARRIAGE_RETURN) {
|
|
115
117
|
reader.next();
|
|
116
|
-
if (reader.peek() ===
|
|
118
|
+
if (reader.peek() === LINE_FEED) reader.next();
|
|
117
119
|
else sink({
|
|
118
120
|
code: "pdf/stream-bad-eol",
|
|
119
121
|
severity: "warning",
|
|
@@ -121,7 +123,7 @@ function skipStreamDataStart(reader, sink) {
|
|
|
121
123
|
});
|
|
122
124
|
return;
|
|
123
125
|
}
|
|
124
|
-
if (reader.peek() ===
|
|
126
|
+
if (reader.peek() === LINE_FEED) {
|
|
125
127
|
reader.next();
|
|
126
128
|
return;
|
|
127
129
|
}
|
|
@@ -187,8 +189,8 @@ function findEndstreamOffset(reader, fromOffset) {
|
|
|
187
189
|
}
|
|
188
190
|
function trimTrailingStreamEol(reader, dataStart, endstreamOffset) {
|
|
189
191
|
const precedingTwo = reader.slice(Math.max(dataStart, endstreamOffset - 2), endstreamOffset);
|
|
190
|
-
if (precedingTwo.length >= 2 && precedingTwo[precedingTwo.length - 2] ===
|
|
191
|
-
if (precedingTwo.length >= 1 && (precedingTwo[precedingTwo.length - 1] ===
|
|
192
|
+
if (precedingTwo.length >= 2 && precedingTwo[precedingTwo.length - 2] === CARRIAGE_RETURN && precedingTwo[precedingTwo.length - 1] === LINE_FEED) return endstreamOffset - 2;
|
|
193
|
+
if (precedingTwo.length >= 1 && (precedingTwo[precedingTwo.length - 1] === LINE_FEED || precedingTwo[precedingTwo.length - 1] === CARRIAGE_RETURN)) return endstreamOffset - 1;
|
|
192
194
|
return endstreamOffset;
|
|
193
195
|
}
|
|
194
196
|
function parseIndirectObject(reader, sink) {
|