pdf-codec 5.8.1 → 5.8.3
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/README.md +4 -0
- package/dist/builtin-encoding.cjs +1 -1
- package/dist/builtin-encoding.js +2 -2
- package/dist/core-font-glyph-orders.cjs +97 -0
- package/dist/core-font-glyph-orders.d.cts +23 -1
- package/dist/core-font-glyph-orders.d.ts +23 -1
- package/dist/core-font-glyph-orders.js +95 -1
- package/dist/font-read.cjs +46 -0
- package/dist/font-read.d.cts +3 -0
- package/dist/font-read.d.ts +3 -0
- package/dist/font-read.js +46 -0
- package/dist/verified-glyph-tables-B_ZoMhyT.d.cts +38 -0
- package/dist/verified-glyph-tables-B_ZoMhyT.d.ts +38 -0
- package/dist/verified-glyph-tables.cjs +398 -0
- package/dist/verified-glyph-tables.d.cts +2 -0
- package/dist/verified-glyph-tables.d.ts +2 -0
- package/dist/verified-glyph-tables.js +393 -0
- package/package.json +1 -1
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { sha256 } from "./crypto/sha2.js";
|
|
2
|
+
//#region src/verified-glyph-tables.ts
|
|
3
|
+
const HEX_RADIX = 16;
|
|
4
|
+
const HEX_DIGITS_PER_BYTE = 2;
|
|
5
|
+
/**
|
|
6
|
+
* The SHA-256 of a decoded font program as lower-case hex, the key the verified subsets are filed under.
|
|
7
|
+
* @param bytes - The decoded bytes of the embedded font program.
|
|
8
|
+
* @returns The digest.
|
|
9
|
+
*/
|
|
10
|
+
function programDigest(bytes) {
|
|
11
|
+
return Array.from(sha256(bytes), (byte) => byte.toString(HEX_RADIX).padStart(HEX_DIGITS_PER_BYTE, "0")).join("");
|
|
12
|
+
}
|
|
13
|
+
/** The subsets checked so far, by the SHA-256 of the decoded font program. */
|
|
14
|
+
const VERIFIED_SOURCES = /* @__PURE__ */ new Map([
|
|
15
|
+
["f483d278b1ade68af30ba62e57752933bccea6ee61d388fbf73ed2047feb620c", {
|
|
16
|
+
family: "AdvP4C4E74",
|
|
17
|
+
glyphs: {
|
|
18
|
+
onequarter: "=",
|
|
19
|
+
thorn: "+"
|
|
20
|
+
}
|
|
21
|
+
}],
|
|
22
|
+
["40b088a33057f42fdb763f1eb9e849574a925ce59e413a0e94617b3333b40056", {
|
|
23
|
+
family: "AdvMT_MI",
|
|
24
|
+
glyphs: {
|
|
25
|
+
C11: "α",
|
|
26
|
+
C12: "β",
|
|
27
|
+
C13: "γ",
|
|
28
|
+
C14: "δ",
|
|
29
|
+
C15: "ϵ",
|
|
30
|
+
C17: "η",
|
|
31
|
+
C18: "θ",
|
|
32
|
+
C20: "κ",
|
|
33
|
+
C21: "λ",
|
|
34
|
+
C22: "μ",
|
|
35
|
+
C23: "ν",
|
|
36
|
+
C25: "π",
|
|
37
|
+
C26: "ρ",
|
|
38
|
+
C27: "σ",
|
|
39
|
+
C28: "τ",
|
|
40
|
+
C30: "ϕ",
|
|
41
|
+
C31: "χ",
|
|
42
|
+
at: "∂",
|
|
43
|
+
colon: ".",
|
|
44
|
+
equal: "/",
|
|
45
|
+
exclam: "ω",
|
|
46
|
+
greater: ">",
|
|
47
|
+
less: "<",
|
|
48
|
+
quotedbl: "ε",
|
|
49
|
+
semicolon: ","
|
|
50
|
+
}
|
|
51
|
+
}],
|
|
52
|
+
["99212d4f61280dcc8ca4377fca8259451eb05e0867a0017c0c41a521cd9fffac", {
|
|
53
|
+
family: "AdvMT_SY",
|
|
54
|
+
glyphs: {
|
|
55
|
+
C0: "−",
|
|
56
|
+
C1: "⋅",
|
|
57
|
+
C138: "]",
|
|
58
|
+
C14: "○",
|
|
59
|
+
C17: "≡",
|
|
60
|
+
C18: "⊆",
|
|
61
|
+
C2: "×",
|
|
62
|
+
C20: "≤",
|
|
63
|
+
C21: "≥",
|
|
64
|
+
C22: "≼",
|
|
65
|
+
C25: "≈",
|
|
66
|
+
C26: "⊂",
|
|
67
|
+
C27: "⊃",
|
|
68
|
+
C28: "≪",
|
|
69
|
+
C29: "≫",
|
|
70
|
+
C3: "∗",
|
|
71
|
+
C30: "≺",
|
|
72
|
+
C6: "±",
|
|
73
|
+
R: "ℛ",
|
|
74
|
+
Thorn: ")",
|
|
75
|
+
b: "⌊",
|
|
76
|
+
backslash: "∩",
|
|
77
|
+
bracketleft: "∪",
|
|
78
|
+
c: "⌋",
|
|
79
|
+
dollar: "↔",
|
|
80
|
+
eth: "(",
|
|
81
|
+
exclam: "→",
|
|
82
|
+
f: "{",
|
|
83
|
+
ff: "∠",
|
|
84
|
+
ffi: "≅",
|
|
85
|
+
g: "}",
|
|
86
|
+
j: "|",
|
|
87
|
+
k: "‖",
|
|
88
|
+
numbersign: "↓",
|
|
89
|
+
one: "∞",
|
|
90
|
+
onehalf: "[",
|
|
91
|
+
onequarter: "=",
|
|
92
|
+
p: "√",
|
|
93
|
+
parenright: "⇒",
|
|
94
|
+
quoteright: "≃",
|
|
95
|
+
r: "∇",
|
|
96
|
+
six: "/",
|
|
97
|
+
thorn: "+",
|
|
98
|
+
two: "∈",
|
|
99
|
+
zero: "′"
|
|
100
|
+
}
|
|
101
|
+
}],
|
|
102
|
+
["53ea45831e6c9133d4bb030d84cc8888bfa065dc98a66b9229b2b578f7a2f615", {
|
|
103
|
+
family: "AdvP4C4E46",
|
|
104
|
+
glyphs: {
|
|
105
|
+
C0: "(",
|
|
106
|
+
C1: ")",
|
|
107
|
+
C16: "(",
|
|
108
|
+
C17: ")",
|
|
109
|
+
C18: "(",
|
|
110
|
+
C19: ")",
|
|
111
|
+
p: "√",
|
|
112
|
+
q: "√",
|
|
113
|
+
r: "√",
|
|
114
|
+
s: "√"
|
|
115
|
+
}
|
|
116
|
+
}],
|
|
117
|
+
["6071bcddbb9aa9d41a695f93ec76b9aacd2fee29325cc5a75e05ec39cbe419ac", {
|
|
118
|
+
family: "AdvP4C4E46",
|
|
119
|
+
glyphs: {
|
|
120
|
+
C0: "(",
|
|
121
|
+
C1: ")",
|
|
122
|
+
C16: "(",
|
|
123
|
+
C17: ")",
|
|
124
|
+
C18: "(",
|
|
125
|
+
C19: ")",
|
|
126
|
+
p: "√",
|
|
127
|
+
r: "√"
|
|
128
|
+
}
|
|
129
|
+
}],
|
|
130
|
+
["60efa155cc8d0a1bbe67f3926b42c856e503074caff150fd2ff6075f0b723ef2", {
|
|
131
|
+
family: "AdvP4C4E46",
|
|
132
|
+
glyphs: {
|
|
133
|
+
C0: "(",
|
|
134
|
+
C1: ")",
|
|
135
|
+
C16: "(",
|
|
136
|
+
C17: ")",
|
|
137
|
+
C18: "(",
|
|
138
|
+
C19: ")",
|
|
139
|
+
C20: "[",
|
|
140
|
+
C21: "]",
|
|
141
|
+
C26: "{",
|
|
142
|
+
C27: "}",
|
|
143
|
+
Eth: "∫",
|
|
144
|
+
P: "∑",
|
|
145
|
+
X: "∑",
|
|
146
|
+
asciicircum: "⋀",
|
|
147
|
+
backslash: "⋂",
|
|
148
|
+
eth: "∫",
|
|
149
|
+
exclam: ")",
|
|
150
|
+
five: "⎦",
|
|
151
|
+
four: "⎣",
|
|
152
|
+
h: "[",
|
|
153
|
+
i: "]",
|
|
154
|
+
numbersign: "]",
|
|
155
|
+
p: "√",
|
|
156
|
+
parenleft: "{",
|
|
157
|
+
q: "√",
|
|
158
|
+
quotedbl: "[",
|
|
159
|
+
r: "√",
|
|
160
|
+
s: "√",
|
|
161
|
+
space: "(",
|
|
162
|
+
three: "⎤",
|
|
163
|
+
two: "⎡"
|
|
164
|
+
}
|
|
165
|
+
}],
|
|
166
|
+
["a8442ad73af43eb9abec5cb790fe053953caf2cba069038689c1091a8bf1da57", {
|
|
167
|
+
family: "AdvP4C4E46",
|
|
168
|
+
glyphs: {
|
|
169
|
+
C0: "(",
|
|
170
|
+
C1: ")",
|
|
171
|
+
C16: "(",
|
|
172
|
+
C17: ")",
|
|
173
|
+
C18: "(",
|
|
174
|
+
C19: ")",
|
|
175
|
+
C20: "[",
|
|
176
|
+
C21: "]",
|
|
177
|
+
C26: "{",
|
|
178
|
+
C27: "}",
|
|
179
|
+
Eth: "∫",
|
|
180
|
+
P: "∑",
|
|
181
|
+
eth: "∫",
|
|
182
|
+
five: "⎦",
|
|
183
|
+
four: "⎣",
|
|
184
|
+
h: "[",
|
|
185
|
+
i: "]",
|
|
186
|
+
p: "√",
|
|
187
|
+
q: "√",
|
|
188
|
+
r: "√",
|
|
189
|
+
three: "⎤",
|
|
190
|
+
two: "⎡"
|
|
191
|
+
}
|
|
192
|
+
}],
|
|
193
|
+
["f2c12f17afd97014ccf6002befb9a7fa5c9156788bb9a616a5f9d31f8b5aaedd", {
|
|
194
|
+
family: "AdvP4C4E46",
|
|
195
|
+
glyphs: {
|
|
196
|
+
C16: "(",
|
|
197
|
+
C17: ")",
|
|
198
|
+
C18: "(",
|
|
199
|
+
C19: ")",
|
|
200
|
+
C20: "[",
|
|
201
|
+
C21: "]",
|
|
202
|
+
exclam: ")",
|
|
203
|
+
five: "⎦",
|
|
204
|
+
four: "⎣",
|
|
205
|
+
h: "[",
|
|
206
|
+
i: "]",
|
|
207
|
+
p: "√",
|
|
208
|
+
q: "√",
|
|
209
|
+
r: "√",
|
|
210
|
+
space: "(",
|
|
211
|
+
three: "⎤",
|
|
212
|
+
two: "⎡"
|
|
213
|
+
}
|
|
214
|
+
}],
|
|
215
|
+
["93463c42e9491b79f82f761b522ae2de72b6217efccd186930df7237ef8002ef", {
|
|
216
|
+
family: "AdvP4C4E51",
|
|
217
|
+
glyphs: {
|
|
218
|
+
colon: ".",
|
|
219
|
+
equal: "/",
|
|
220
|
+
greater: ">",
|
|
221
|
+
less: "<",
|
|
222
|
+
semicolon: ","
|
|
223
|
+
}
|
|
224
|
+
}],
|
|
225
|
+
["967c167a737966cddc29a62e6f0601efc797d1f9453d0f3df558306b2d8b91e2", {
|
|
226
|
+
family: "AdvP4C4E59",
|
|
227
|
+
glyphs: {
|
|
228
|
+
C1: "Δ",
|
|
229
|
+
C10: "Ω"
|
|
230
|
+
}
|
|
231
|
+
}],
|
|
232
|
+
["38c8aa8ccee56512b9816a6c93c2e2b166166b672560b5f827eef19c43626bd3", {
|
|
233
|
+
family: "AdvP4C4E74",
|
|
234
|
+
glyphs: {
|
|
235
|
+
C0: "−",
|
|
236
|
+
C14: "○",
|
|
237
|
+
C2: "×",
|
|
238
|
+
C20: "≤",
|
|
239
|
+
C21: "≥",
|
|
240
|
+
C3: "∗",
|
|
241
|
+
C6: "±",
|
|
242
|
+
Thorn: ")",
|
|
243
|
+
eth: "(",
|
|
244
|
+
onequarter: "=",
|
|
245
|
+
p: "√",
|
|
246
|
+
slash: "∝",
|
|
247
|
+
thorn: "+",
|
|
248
|
+
zero: "′"
|
|
249
|
+
}
|
|
250
|
+
}],
|
|
251
|
+
["4061cae07e31ac6441fef12114942a58d0bae5f64a0789932ee703654990a769", {
|
|
252
|
+
family: "AdvP4C4E74",
|
|
253
|
+
glyphs: {
|
|
254
|
+
C0: "−",
|
|
255
|
+
C1: "⋅",
|
|
256
|
+
C138: "]",
|
|
257
|
+
C14: "○",
|
|
258
|
+
C2: "×",
|
|
259
|
+
C20: "≤",
|
|
260
|
+
C21: "≥",
|
|
261
|
+
C6: "±",
|
|
262
|
+
C8: "⊕",
|
|
263
|
+
Thorn: ")",
|
|
264
|
+
eth: "(",
|
|
265
|
+
f: "{",
|
|
266
|
+
ff: "∠",
|
|
267
|
+
g: "}",
|
|
268
|
+
j: "|",
|
|
269
|
+
onehalf: "[",
|
|
270
|
+
onequarter: "=",
|
|
271
|
+
p: "√",
|
|
272
|
+
parenright: "⇒",
|
|
273
|
+
slash: "∝",
|
|
274
|
+
thorn: "+",
|
|
275
|
+
zero: "′"
|
|
276
|
+
}
|
|
277
|
+
}],
|
|
278
|
+
["4983c0bc19d073482c226511409622f6009444f10660bd4d6fd146e876af1eb0", {
|
|
279
|
+
family: "AdvP4C4E74",
|
|
280
|
+
glyphs: {
|
|
281
|
+
C0: "−",
|
|
282
|
+
C1: "⋅",
|
|
283
|
+
C138: "]",
|
|
284
|
+
C14: "○",
|
|
285
|
+
C2: "×",
|
|
286
|
+
C20: "≤",
|
|
287
|
+
C3: "∗",
|
|
288
|
+
C6: "±",
|
|
289
|
+
Thorn: ")",
|
|
290
|
+
eth: "(",
|
|
291
|
+
f: "{",
|
|
292
|
+
ff: "∠",
|
|
293
|
+
g: "}",
|
|
294
|
+
numbersign: "↓",
|
|
295
|
+
onehalf: "[",
|
|
296
|
+
onequarter: "=",
|
|
297
|
+
p: "√",
|
|
298
|
+
slash: "∝",
|
|
299
|
+
thorn: "+"
|
|
300
|
+
}
|
|
301
|
+
}],
|
|
302
|
+
["ccf77c4a71142b8025af5b751a4cc473204521ea2eddcf1d91f1713182c5aecf", {
|
|
303
|
+
family: "AdvP4C4E74",
|
|
304
|
+
glyphs: {
|
|
305
|
+
C0: "−",
|
|
306
|
+
C1: "⋅",
|
|
307
|
+
C138: "]",
|
|
308
|
+
C14: "○",
|
|
309
|
+
C15: "●",
|
|
310
|
+
C2: "×",
|
|
311
|
+
C20: "≤",
|
|
312
|
+
C21: "≥",
|
|
313
|
+
C24: "∼",
|
|
314
|
+
C25: "≈",
|
|
315
|
+
C29: "≫",
|
|
316
|
+
C3: "∗",
|
|
317
|
+
C6: "±",
|
|
318
|
+
Thorn: ")",
|
|
319
|
+
b: "⌊",
|
|
320
|
+
c: "⌋",
|
|
321
|
+
eth: "(",
|
|
322
|
+
exclam: "→",
|
|
323
|
+
f: "{",
|
|
324
|
+
ff: "∠",
|
|
325
|
+
ffi: "≅",
|
|
326
|
+
g: "}",
|
|
327
|
+
j: "|",
|
|
328
|
+
one: "∞",
|
|
329
|
+
onehalf: "[",
|
|
330
|
+
onequarter: "=",
|
|
331
|
+
p: "√",
|
|
332
|
+
parenright: "⇒",
|
|
333
|
+
r: "∇",
|
|
334
|
+
six: "/",
|
|
335
|
+
slash: "∝",
|
|
336
|
+
space: "←",
|
|
337
|
+
thorn: "+",
|
|
338
|
+
two: "∈",
|
|
339
|
+
zero: "′"
|
|
340
|
+
}
|
|
341
|
+
}],
|
|
342
|
+
["dc3008dbca19a91b63116bcfed491a45776faffadc2c8063b5367c71bf1657d1", {
|
|
343
|
+
family: "AdvP4C4E74",
|
|
344
|
+
glyphs: {
|
|
345
|
+
C0: "−",
|
|
346
|
+
C138: "]",
|
|
347
|
+
C14: "○",
|
|
348
|
+
C2: "×",
|
|
349
|
+
C20: "≤",
|
|
350
|
+
C21: "≥",
|
|
351
|
+
C4: "÷",
|
|
352
|
+
C6: "±",
|
|
353
|
+
Thorn: ")",
|
|
354
|
+
eth: "(",
|
|
355
|
+
onehalf: "[",
|
|
356
|
+
onequarter: "=",
|
|
357
|
+
p: "√",
|
|
358
|
+
slash: "∝",
|
|
359
|
+
thorn: "+"
|
|
360
|
+
}
|
|
361
|
+
}]
|
|
362
|
+
]);
|
|
363
|
+
function tableOf(source) {
|
|
364
|
+
return {
|
|
365
|
+
family: source.family,
|
|
366
|
+
glyphs: new Map(Object.entries(source.glyphs))
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
/** The font families some verified subset belongs to: a font of any other family is not hashed. */
|
|
370
|
+
const VERIFIED_GLYPH_FAMILIES = new Set([...VERIFIED_SOURCES.values()].map((source) => source.family));
|
|
371
|
+
/**
|
|
372
|
+
* The verified table for an embedded font program given its digest, or `undefined` for any program that is not exactly one that was checked.
|
|
373
|
+
* @param family - The font's family as `styleFromBaseFontName` reads it: the table is used only for a font whose family is the one it was checked for.
|
|
374
|
+
* @param digest - The SHA-256 of the decoded font program (`programDigest`).
|
|
375
|
+
* @param tables - The verified subsets to look in, by program SHA-256; the checked ones unless a test supplies its own.
|
|
376
|
+
* @returns The table for that subset, or `undefined`.
|
|
377
|
+
*/
|
|
378
|
+
function verifiedGlyphTableOfDigest(family, digest, tables = VERIFIED_SOURCES) {
|
|
379
|
+
const source = tables.get(digest);
|
|
380
|
+
return source?.family === family ? tableOf(source) : void 0;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* The verified table for an embedded font program, or `undefined` for any program that is not exactly one that was checked.
|
|
384
|
+
* @param family - The font's family as `styleFromBaseFontName` reads it: the table is used only for a font whose family is the one it was checked for.
|
|
385
|
+
* @param program - The decoded bytes of the embedded font program.
|
|
386
|
+
* @param tables - The verified subsets to look in, by program SHA-256; the checked ones unless a test supplies its own.
|
|
387
|
+
* @returns The table for that subset, or `undefined`.
|
|
388
|
+
*/
|
|
389
|
+
function verifiedGlyphTableFor(family, program, tables = VERIFIED_SOURCES) {
|
|
390
|
+
return verifiedGlyphTableOfDigest(family, programDigest(program), tables);
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
export { VERIFIED_GLYPH_FAMILIES, VERIFIED_SOURCES, programDigest, verifiedGlyphTableFor, verifiedGlyphTableOfDigest };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdf-codec",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.3",
|
|
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": {
|