pdf-codec 3.5.1 → 3.5.2
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-BLl6ORCt.js → afm-widths-B6KdmpRF.js} +875 -2
- package/dist/{afm-widths-Cj9d3GVK.cjs → afm-widths-W02fJh-k.cjs} +898 -1
- package/dist/afm-widths.cjs +1 -1
- package/dist/afm-widths.js +1 -1
- package/dist/content-write.cjs +1 -1
- package/dist/content-write.js +1 -1
- package/dist/encoding.cjs +5 -1
- package/dist/encoding.d.cts +5 -1
- package/dist/encoding.d.ts +5 -1
- package/dist/encoding.js +2 -2
- package/dist/font-read.cjs +14 -4
- package/dist/font-read.js +14 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/measure.cjs +1 -1
- package/dist/measure.js +1 -1
- package/dist/winansi.cjs +1 -1
- package/dist/winansi.js +1 -1
- package/dist/write.cjs +1 -1
- package/dist/write.js +1 -1
- package/package.json +1 -1
package/dist/afm-widths.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-W02fJh-k.cjs");
|
|
3
3
|
exports.STANDARD_METRICS = require_afm_widths.STANDARD_METRICS;
|
|
4
4
|
exports.widthOfCode = require_afm_widths.widthOfCode;
|
package/dist/afm-widths.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as widthOfCode, t as STANDARD_METRICS } from "./afm-widths-
|
|
1
|
+
import { n as widthOfCode, t as STANDARD_METRICS } from "./afm-widths-B6KdmpRF.js";
|
|
2
2
|
export { STANDARD_METRICS, widthOfCode };
|
package/dist/content-write.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-W02fJh-k.cjs");
|
|
3
3
|
const require_objects = require("./objects.cjs");
|
|
4
4
|
const require_bytes_writer = require("./bytes/writer.cjs");
|
|
5
5
|
const require_serialize = require("./serialize.cjs");
|
package/dist/content-write.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { u as encodeForShow } from "./afm-widths-B6KdmpRF.js";
|
|
2
2
|
import { pdfArray, pdfHexString, pdfNum } from "./objects.js";
|
|
3
3
|
import { ByteWriter } from "./bytes/writer.js";
|
|
4
4
|
import { formatNumber, writeObject } from "./serialize.js";
|
package/dist/encoding.cjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
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-W02fJh-k.cjs");
|
|
3
|
+
exports.SYMBOL_GLYPH_NAMES = require_afm_widths.SYMBOL_GLYPH_NAMES;
|
|
3
4
|
exports.WINANSI_GLYPH_NAMES = require_afm_widths.WINANSI_GLYPH_NAMES;
|
|
5
|
+
exports.ZAPFDINGBATS_GLYPH_NAMES = require_afm_widths.ZAPFDINGBATS_GLYPH_NAMES;
|
|
4
6
|
exports.glyphNameToUnicode = require_afm_widths.glyphNameToUnicode;
|
|
7
|
+
exports.symbolGlyphName = require_afm_widths.symbolGlyphName;
|
|
5
8
|
exports.winAnsiGlyphName = require_afm_widths.winAnsiGlyphName;
|
|
9
|
+
exports.zapfDingbatsGlyphName = require_afm_widths.zapfDingbatsGlyphName;
|
package/dist/encoding.d.cts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
//#region src/encoding.d.ts
|
|
2
2
|
declare const WINANSI_GLYPH_NAMES: readonly string[];
|
|
3
3
|
declare function winAnsiGlyphName(code: number): string | undefined;
|
|
4
|
+
declare const SYMBOL_GLYPH_NAMES: readonly string[];
|
|
5
|
+
declare function symbolGlyphName(code: number): string | undefined;
|
|
6
|
+
declare const ZAPFDINGBATS_GLYPH_NAMES: readonly string[];
|
|
7
|
+
declare function zapfDingbatsGlyphName(code: number): string | undefined;
|
|
4
8
|
declare function glyphNameToUnicode(name: string): number | undefined;
|
|
5
9
|
//#endregion
|
|
6
|
-
export { WINANSI_GLYPH_NAMES, glyphNameToUnicode, winAnsiGlyphName };
|
|
10
|
+
export { SYMBOL_GLYPH_NAMES, WINANSI_GLYPH_NAMES, ZAPFDINGBATS_GLYPH_NAMES, glyphNameToUnicode, symbolGlyphName, winAnsiGlyphName, zapfDingbatsGlyphName };
|
package/dist/encoding.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
//#region src/encoding.d.ts
|
|
2
2
|
declare const WINANSI_GLYPH_NAMES: readonly string[];
|
|
3
3
|
declare function winAnsiGlyphName(code: number): string | undefined;
|
|
4
|
+
declare const SYMBOL_GLYPH_NAMES: readonly string[];
|
|
5
|
+
declare function symbolGlyphName(code: number): string | undefined;
|
|
6
|
+
declare const ZAPFDINGBATS_GLYPH_NAMES: readonly string[];
|
|
7
|
+
declare function zapfDingbatsGlyphName(code: number): string | undefined;
|
|
4
8
|
declare function glyphNameToUnicode(name: string): number | undefined;
|
|
5
9
|
//#endregion
|
|
6
|
-
export { WINANSI_GLYPH_NAMES, glyphNameToUnicode, winAnsiGlyphName };
|
|
10
|
+
export { SYMBOL_GLYPH_NAMES, WINANSI_GLYPH_NAMES, ZAPFDINGBATS_GLYPH_NAMES, glyphNameToUnicode, symbolGlyphName, winAnsiGlyphName, zapfDingbatsGlyphName };
|
package/dist/encoding.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as winAnsiGlyphName, i as glyphNameToUnicode, r as
|
|
2
|
-
export { WINANSI_GLYPH_NAMES, glyphNameToUnicode, winAnsiGlyphName };
|
|
1
|
+
import { a as ZAPFDINGBATS_GLYPH_NAMES, c as winAnsiGlyphName, i as WINANSI_GLYPH_NAMES, l as zapfDingbatsGlyphName, o as glyphNameToUnicode, r as SYMBOL_GLYPH_NAMES, s as symbolGlyphName } from "./afm-widths-B6KdmpRF.js";
|
|
2
|
+
export { SYMBOL_GLYPH_NAMES, WINANSI_GLYPH_NAMES, ZAPFDINGBATS_GLYPH_NAMES, glyphNameToUnicode, symbolGlyphName, winAnsiGlyphName, zapfDingbatsGlyphName };
|
package/dist/font-read.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
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-W02fJh-k.cjs");
|
|
3
3
|
const require_objects = require("./objects.cjs");
|
|
4
4
|
const require_filters = require("./filters.cjs");
|
|
5
5
|
const require_cmap = require("./cmap.cjs");
|
|
6
6
|
const require_fonts = require("./fonts.cjs");
|
|
7
7
|
const require_font_style = require("./font-style.cjs");
|
|
8
8
|
//#region src/font-read.ts
|
|
9
|
+
const SYMBOLIC_FLAG_BIT = 4;
|
|
9
10
|
const ITALIC_FLAG_BIT = 64;
|
|
10
11
|
const FORCE_BOLD_FLAG_BIT = 1 << 18;
|
|
11
12
|
const REPLACEMENT_CHARACTER = "�";
|
|
@@ -14,9 +15,14 @@ function styleFlagsFromDescriptor(descriptor) {
|
|
|
14
15
|
return {
|
|
15
16
|
forceBold: flags !== void 0 ? (flags & FORCE_BOLD_FLAG_BIT) !== 0 : void 0,
|
|
16
17
|
italicFlag: flags !== void 0 ? (flags & ITALIC_FLAG_BIT) !== 0 : void 0,
|
|
17
|
-
italicAngle: descriptor !== void 0 ? require_objects.asNumber(require_objects.dictGet(descriptor, "ItalicAngle")) : void 0
|
|
18
|
+
italicAngle: descriptor !== void 0 ? require_objects.asNumber(require_objects.dictGet(descriptor, "ItalicAngle")) : void 0,
|
|
19
|
+
symbolic: flags !== void 0 ? (flags & SYMBOLIC_FLAG_BIT) !== 0 : void 0
|
|
18
20
|
};
|
|
19
21
|
}
|
|
22
|
+
function builtinSymbolGlyphNameLookup(baseFamily) {
|
|
23
|
+
if (baseFamily === "Symbol") return require_afm_widths.symbolGlyphName;
|
|
24
|
+
if (baseFamily === "ZapfDingbats") return require_afm_widths.zapfDingbatsGlyphName;
|
|
25
|
+
}
|
|
20
26
|
function glyphNameToUnicodeWithUniFallback(name) {
|
|
21
27
|
const direct = require_afm_widths.glyphNameToUnicode(name);
|
|
22
28
|
if (direct !== void 0) return direct;
|
|
@@ -43,7 +49,10 @@ function readToUnicodeCMap(fontDict, context) {
|
|
|
43
49
|
function buildSimpleFont(fontDict, context) {
|
|
44
50
|
const baseFont = require_objects.asName(require_objects.dictGet(fontDict, "BaseFont")) ?? "Helvetica";
|
|
45
51
|
const descriptor = context.resolver.resolveDict(require_objects.dictGet(fontDict, "FontDescriptor"));
|
|
46
|
-
const
|
|
52
|
+
const styleFlags = styleFlagsFromDescriptor(descriptor);
|
|
53
|
+
const { baseFamily, bold, italic } = require_font_style.styleFromBaseFontName(baseFont, styleFlags);
|
|
54
|
+
const symbolic = styleFlags.symbolic ?? false;
|
|
55
|
+
const builtinGlyphName = builtinSymbolGlyphNameLookup(baseFamily);
|
|
47
56
|
const widthsArr = require_objects.asArray(require_objects.dictGet(fontDict, "Widths"));
|
|
48
57
|
const firstChar = require_objects.asNumber(require_objects.dictGet(fontDict, "FirstChar")) ?? 0;
|
|
49
58
|
const missingWidth = (descriptor !== void 0 ? require_objects.asNumber(require_objects.dictGet(descriptor, "MissingWidth")) : void 0) ?? 0;
|
|
@@ -68,6 +77,7 @@ function buildSimpleFont(fontDict, context) {
|
|
|
68
77
|
message: `base encoding "${baseEncodingName}" has no dedicated table here and is approximated as WinAnsiEncoding`
|
|
69
78
|
});
|
|
70
79
|
const differencesMap = readDifferencesMap(encodingDict !== void 0 ? require_objects.asArray(require_objects.dictGet(encodingDict, "Differences")) : void 0);
|
|
80
|
+
const fallbackGlyphName = builtinGlyphName ?? (symbolic ? () => void 0 : require_afm_widths.winAnsiGlyphName);
|
|
71
81
|
const decodeToUnicode = (codes) => {
|
|
72
82
|
let out = "";
|
|
73
83
|
let unmapped = 0;
|
|
@@ -77,7 +87,7 @@ function buildSimpleFont(fontDict, context) {
|
|
|
77
87
|
out += viaToUnicode;
|
|
78
88
|
continue;
|
|
79
89
|
}
|
|
80
|
-
const name = differencesMap.get(code) ??
|
|
90
|
+
const name = differencesMap.get(code) ?? fallbackGlyphName(code);
|
|
81
91
|
const unicode = name !== void 0 ? glyphNameToUnicodeWithUniFallback(name) : void 0;
|
|
82
92
|
if (unicode !== void 0) {
|
|
83
93
|
out += String.fromCharCode(unicode);
|
package/dist/font-read.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as winAnsiGlyphName, l as zapfDingbatsGlyphName, n as widthOfCode, o as glyphNameToUnicode, s as symbolGlyphName } from "./afm-widths-B6KdmpRF.js";
|
|
2
2
|
import { asArray, asName, asNumber, dictGet } from "./objects.js";
|
|
3
3
|
import { decodeStream } from "./filters.js";
|
|
4
4
|
import { parseToUnicodeCMap } from "./cmap.js";
|
|
5
5
|
import { resolveStandardFont } from "./fonts.js";
|
|
6
6
|
import { styleFromBaseFontName } from "./font-style.js";
|
|
7
7
|
//#region src/font-read.ts
|
|
8
|
+
const SYMBOLIC_FLAG_BIT = 4;
|
|
8
9
|
const ITALIC_FLAG_BIT = 64;
|
|
9
10
|
const FORCE_BOLD_FLAG_BIT = 1 << 18;
|
|
10
11
|
const REPLACEMENT_CHARACTER = "�";
|
|
@@ -13,9 +14,14 @@ function styleFlagsFromDescriptor(descriptor) {
|
|
|
13
14
|
return {
|
|
14
15
|
forceBold: flags !== void 0 ? (flags & FORCE_BOLD_FLAG_BIT) !== 0 : void 0,
|
|
15
16
|
italicFlag: flags !== void 0 ? (flags & ITALIC_FLAG_BIT) !== 0 : void 0,
|
|
16
|
-
italicAngle: descriptor !== void 0 ? asNumber(dictGet(descriptor, "ItalicAngle")) : void 0
|
|
17
|
+
italicAngle: descriptor !== void 0 ? asNumber(dictGet(descriptor, "ItalicAngle")) : void 0,
|
|
18
|
+
symbolic: flags !== void 0 ? (flags & SYMBOLIC_FLAG_BIT) !== 0 : void 0
|
|
17
19
|
};
|
|
18
20
|
}
|
|
21
|
+
function builtinSymbolGlyphNameLookup(baseFamily) {
|
|
22
|
+
if (baseFamily === "Symbol") return symbolGlyphName;
|
|
23
|
+
if (baseFamily === "ZapfDingbats") return zapfDingbatsGlyphName;
|
|
24
|
+
}
|
|
19
25
|
function glyphNameToUnicodeWithUniFallback(name) {
|
|
20
26
|
const direct = glyphNameToUnicode(name);
|
|
21
27
|
if (direct !== void 0) return direct;
|
|
@@ -42,7 +48,10 @@ function readToUnicodeCMap(fontDict, context) {
|
|
|
42
48
|
function buildSimpleFont(fontDict, context) {
|
|
43
49
|
const baseFont = asName(dictGet(fontDict, "BaseFont")) ?? "Helvetica";
|
|
44
50
|
const descriptor = context.resolver.resolveDict(dictGet(fontDict, "FontDescriptor"));
|
|
45
|
-
const
|
|
51
|
+
const styleFlags = styleFlagsFromDescriptor(descriptor);
|
|
52
|
+
const { baseFamily, bold, italic } = styleFromBaseFontName(baseFont, styleFlags);
|
|
53
|
+
const symbolic = styleFlags.symbolic ?? false;
|
|
54
|
+
const builtinGlyphName = builtinSymbolGlyphNameLookup(baseFamily);
|
|
46
55
|
const widthsArr = asArray(dictGet(fontDict, "Widths"));
|
|
47
56
|
const firstChar = asNumber(dictGet(fontDict, "FirstChar")) ?? 0;
|
|
48
57
|
const missingWidth = (descriptor !== void 0 ? asNumber(dictGet(descriptor, "MissingWidth")) : void 0) ?? 0;
|
|
@@ -67,6 +76,7 @@ function buildSimpleFont(fontDict, context) {
|
|
|
67
76
|
message: `base encoding "${baseEncodingName}" has no dedicated table here and is approximated as WinAnsiEncoding`
|
|
68
77
|
});
|
|
69
78
|
const differencesMap = readDifferencesMap(encodingDict !== void 0 ? asArray(dictGet(encodingDict, "Differences")) : void 0);
|
|
79
|
+
const fallbackGlyphName = builtinGlyphName ?? (symbolic ? () => void 0 : winAnsiGlyphName);
|
|
70
80
|
const decodeToUnicode = (codes) => {
|
|
71
81
|
let out = "";
|
|
72
82
|
let unmapped = 0;
|
|
@@ -76,7 +86,7 @@ function buildSimpleFont(fontDict, context) {
|
|
|
76
86
|
out += viaToUnicode;
|
|
77
87
|
continue;
|
|
78
88
|
}
|
|
79
|
-
const name = differencesMap.get(code) ??
|
|
89
|
+
const name = differencesMap.get(code) ?? fallbackGlyphName(code);
|
|
80
90
|
const unicode = name !== void 0 ? glyphNameToUnicodeWithUniFallback(name) : void 0;
|
|
81
91
|
if (unicode !== void 0) {
|
|
82
92
|
out += String.fromCharCode(unicode);
|
package/dist/index.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-W02fJh-k.cjs");
|
|
3
3
|
const require_image_ccitt = require("./image/ccitt.cjs");
|
|
4
4
|
const require_image_jbig2_errors = require("./image/jbig2-errors.cjs");
|
|
5
5
|
const require_image_jbig2 = require("./image/jbig2.cjs");
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as STANDARD_METRICS } from "./afm-widths-
|
|
1
|
+
import { t as STANDARD_METRICS } from "./afm-widths-B6KdmpRF.js";
|
|
2
2
|
import { decodeCcittFax } from "./image/ccitt.js";
|
|
3
3
|
import { Jbig2ParseError, Jbig2UnsupportedError } from "./image/jbig2-errors.js";
|
|
4
4
|
import { decodeJbig2Embedded } from "./image/jbig2.js";
|
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-W02fJh-k.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 {
|
|
1
|
+
import { t as STANDARD_METRICS, u as encodeForShow } from "./afm-widths-B6KdmpRF.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/winansi.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-W02fJh-k.cjs");
|
|
3
3
|
exports.encodeForShow = require_afm_widths.encodeForShow;
|
|
4
4
|
exports.sanitizeToWinAnsi = require_afm_widths.sanitizeToWinAnsi;
|
|
5
5
|
exports.winAnsiCodeToUnicode = require_afm_widths.winAnsiCodeToUnicode;
|
package/dist/winansi.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as sanitizeToWinAnsi, f as winAnsiCodeToUnicode, u as encodeForShow } from "./afm-widths-B6KdmpRF.js";
|
|
2
2
|
export { encodeForShow, sanitizeToWinAnsi, winAnsiCodeToUnicode };
|
package/dist/write.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-W02fJh-k.cjs");
|
|
3
3
|
const require_notes_annotation_author = require("./notes-annotation-author.cjs");
|
|
4
4
|
const require_objects = require("./objects.cjs");
|
|
5
5
|
const require_bytes_writer = require("./bytes/writer.cjs");
|
package/dist/write.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as winAnsiGlyphName, n as widthOfCode, t as STANDARD_METRICS } from "./afm-widths-B6KdmpRF.js";
|
|
2
2
|
import { NOTES_ANNOTATION_AUTHOR } from "./notes-annotation-author.js";
|
|
3
3
|
import { pdfArray, pdfDict, pdfHexString, pdfName, pdfNull, pdfNum, pdfRef, pdfStream } from "./objects.js";
|
|
4
4
|
import { ByteWriter, concatBytes } from "./bytes/writer.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdf-codec",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2",
|
|
4
4
|
"description": "Hand-written, dependency-minimal PDF codec: parses arbitrary real-world PDFs and generates new ones, built on its own codec-owned LayoutDocument item model and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|