pdf-codec 5.8.2 → 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 +2 -0
- package/dist/font-read.cjs +35 -0
- package/dist/font-read.d.cts +3 -0
- package/dist/font-read.d.ts +3 -0
- package/dist/font-read.js +35 -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
package/README.md
CHANGED
|
@@ -336,6 +336,8 @@ A `/ToUnicode` CMap that a producer writes for the Symbol or Wingdings font (Wor
|
|
|
336
336
|
|
|
337
337
|
Two ways a producer names a core face other than the PostScript name the face's own tables carry are read through the same carried glyph order. A TrueType program Windows-era producers embed under the face's Windows name (`TimesNewRoman`, `Arial,Bold`) is the face `TimesNewRomanPSMT` or `Arial-BoldMT`, still accepted glyph by glyph against the program's own advance widths. And Adobe Acrobat's optimiser rewrites a TrueType face as a CFF subset that names each glyph `G` followed by its glyph id in the face (`G36` is the capital A of Times New Roman) under a font name carrying a size suffix (`Times.New.Roman092`, `Arial.Bold0133`): `coreFaceTextsOfNumberedGlyphs` reads those names through the face's order, but only for a font whose dictionary widths agree with the face's advances over at least five numbered glyphs and nine in ten of them, so a subset of another face, or one too small to tell, is read as before. The Symbol face and the Type 3 fonts such producers also write are not covered: the first has no carried order, and a Type 3 glyph is a drawing procedure with no character.
|
|
338
338
|
|
|
339
|
+
Some producers write the font dictionary's own tables wrong for a symbol subset: a typesetter's Type 1C math fonts give each glyph an arbitrary name, assign the names to codes with `/Differences`, and have a `/ToUnicode` CMap read each name as the character it spells, so an equals sign is read as `¼` and an omega as `!`, from tables that are valid and wrong. `verified-glyph-tables.ts` holds tables for the exact subsets whose glyphs were rendered from the embedded program and checked one by one (`docs/verified-glyph-tables/`), each keyed by the SHA-256 of the decoded font program; a glyph of such a subset is read as what it draws, before the font dictionary's tables, and every other subset, family and code is read as before.
|
|
340
|
+
|
|
339
341
|
**Where nothing states an answer, the answer is the replacement character plus a `text/unmapped-encoding` diagnostic, never a guess.** Cases that reach it in practice: a symbolic font with no embedded program and no `/ToUnicode`; a subsetted font that both strips its glyph names and maps its glyphs only from private-use code points; a nameless, `cmap`-less subset of a face whose glyph order this package does not carry, or of a carried face at a glyph its recorded releases do not number; and a composite font whose `/Encoding` is a CMap other than Identity-H or Identity-V, whose codes reach CIDs this reader does not map. A private-use code point identifies a glyph inside one font and says nothing about the character it draws, so it is treated as no answer rather than a wrong one.
|
|
340
342
|
|
|
341
343
|
## Grouping text runs into lines and words
|
package/dist/font-read.cjs
CHANGED
|
@@ -11,6 +11,7 @@ const require_cmap = require("./cmap.cjs");
|
|
|
11
11
|
const require_encoding_symbol_tables = require("./encoding-symbol-tables.cjs");
|
|
12
12
|
const require_fonts = require("./fonts.cjs");
|
|
13
13
|
const require_symbol_font_private_use = require("./symbol-font-private-use.cjs");
|
|
14
|
+
const require_verified_glyph_tables = require("./verified-glyph-tables.cjs");
|
|
14
15
|
//#region src/font-read.ts
|
|
15
16
|
const BITS_PER_BYTE = 8;
|
|
16
17
|
const SYMBOLIC_FLAG_BIT = 4;
|
|
@@ -51,6 +52,33 @@ function lazyFontProgram(descriptor, baseFont, context) {
|
|
|
51
52
|
return read.encoding;
|
|
52
53
|
};
|
|
53
54
|
}
|
|
55
|
+
function lazyVerifiedGlyphTable(descriptor, family, context) {
|
|
56
|
+
let read;
|
|
57
|
+
return () => {
|
|
58
|
+
if (descriptor === void 0 || !require_verified_glyph_tables.VERIFIED_GLYPH_FAMILIES.has(family)) return;
|
|
59
|
+
read ??= { table: verifiedGlyphTableOfProgram(descriptor, family, context) };
|
|
60
|
+
return read.table;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const PROGRAM_DIGESTS = /* @__PURE__ */ new WeakMap();
|
|
64
|
+
function digestOfFontStream(stream, context) {
|
|
65
|
+
let digest = PROGRAM_DIGESTS.get(stream);
|
|
66
|
+
if (digest === void 0) {
|
|
67
|
+
digest = require_verified_glyph_tables.programDigest(require_filters.decodeStream(stream.raw, stream.dict, context.sink).bytes);
|
|
68
|
+
PROGRAM_DIGESTS.set(stream, digest);
|
|
69
|
+
}
|
|
70
|
+
return digest;
|
|
71
|
+
}
|
|
72
|
+
function verifiedGlyphTableOfProgram(descriptor, family, context) {
|
|
73
|
+
for (const key of [
|
|
74
|
+
"FontFile3",
|
|
75
|
+
"FontFile2",
|
|
76
|
+
"FontFile"
|
|
77
|
+
]) {
|
|
78
|
+
const stream = context.resolver.resolve(require_objects.dictGet(descriptor, key));
|
|
79
|
+
if (stream?.kind === "stream") return require_verified_glyph_tables.verifiedGlyphTableOfDigest(family, digestOfFontStream(stream, context), context.verifiedGlyphTables);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
54
82
|
function readDifferencesMap(differences) {
|
|
55
83
|
const map = /* @__PURE__ */ new Map();
|
|
56
84
|
if (differences === void 0) return map;
|
|
@@ -87,6 +115,7 @@ function buildSimpleFont(fontDict, context) {
|
|
|
87
115
|
const symbolic = styleFlags.symbolic ?? false;
|
|
88
116
|
const builtinGlyphName = builtinSymbolGlyphNameLookup(baseFamily);
|
|
89
117
|
const symbolFont = require_symbol_font_private_use.symbolFontOf(baseFamily);
|
|
118
|
+
const verifiedGlyphs = lazyVerifiedGlyphTable(descriptor, baseFamily, context);
|
|
90
119
|
const widthsArr = resolvedArray(require_objects.dictGet(fontDict, "Widths"), context);
|
|
91
120
|
const firstChar = require_objects.asNumber(require_objects.dictGet(fontDict, "FirstChar")) ?? 0;
|
|
92
121
|
const missingWidth = (descriptor !== void 0 ? require_objects.asNumber(require_objects.dictGet(descriptor, "MissingWidth")) : void 0) ?? 0;
|
|
@@ -171,6 +200,12 @@ function buildSimpleFont(fontDict, context) {
|
|
|
171
200
|
let out = "";
|
|
172
201
|
let unmapped = 0;
|
|
173
202
|
for (const code of codes) {
|
|
203
|
+
const glyphName = differencesMap.get(code) ?? namedBaseGlyphName?.(code);
|
|
204
|
+
const verified = glyphName === void 0 ? void 0 : verifiedGlyphs()?.glyphs.get(glyphName);
|
|
205
|
+
if (verified !== void 0) {
|
|
206
|
+
out += verified;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
174
209
|
const viaToUnicode = toUnicode?.lookup(code);
|
|
175
210
|
if (viaToUnicode !== void 0) {
|
|
176
211
|
out += require_symbol_font_private_use.withSymbolFontCharacters(symbolFont, viaToUnicode);
|
package/dist/font-read.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { i as PdfDiagnosticSink } from "./diagnostics-BkG_Ej2x.cjs";
|
|
2
2
|
import { n as PdfDict } from "./objects-e2RS3-yT.cjs";
|
|
3
3
|
import { FontMetricsPort, PdfObjectResolver } from "./interpret-types.cjs";
|
|
4
|
+
import { i as VerifiedGlyphTableSource } from "./verified-glyph-tables-B_ZoMhyT.cjs";
|
|
4
5
|
//#region src/font-read.d.ts
|
|
5
6
|
interface VerticalGlyphMetrics {
|
|
6
7
|
readonly displacementY: number;
|
|
@@ -19,6 +20,8 @@ interface PdfFont {
|
|
|
19
20
|
interface FontReadContext {
|
|
20
21
|
readonly resolver: PdfObjectResolver;
|
|
21
22
|
readonly sink: PdfDiagnosticSink;
|
|
23
|
+
/** The verified font subsets to read a font through, by the SHA-256 of its decoded program; the subsets `verified-glyph-tables.ts` holds when absent. Supplied by a test that builds its own. */
|
|
24
|
+
readonly verifiedGlyphTables?: ReadonlyMap<string, VerifiedGlyphTableSource>;
|
|
22
25
|
}
|
|
23
26
|
interface FontResolverService {
|
|
24
27
|
readonly metrics: FontMetricsPort;
|
package/dist/font-read.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { i as PdfDiagnosticSink } from "./diagnostics-BkG_Ej2x.js";
|
|
2
2
|
import { n as PdfDict } from "./objects-e2RS3-yT.js";
|
|
3
3
|
import { FontMetricsPort, PdfObjectResolver } from "./interpret-types.js";
|
|
4
|
+
import { i as VerifiedGlyphTableSource } from "./verified-glyph-tables-B_ZoMhyT.js";
|
|
4
5
|
//#region src/font-read.d.ts
|
|
5
6
|
interface VerticalGlyphMetrics {
|
|
6
7
|
readonly displacementY: number;
|
|
@@ -19,6 +20,8 @@ interface PdfFont {
|
|
|
19
20
|
interface FontReadContext {
|
|
20
21
|
readonly resolver: PdfObjectResolver;
|
|
21
22
|
readonly sink: PdfDiagnosticSink;
|
|
23
|
+
/** The verified font subsets to read a font through, by the SHA-256 of its decoded program; the subsets `verified-glyph-tables.ts` holds when absent. Supplied by a test that builds its own. */
|
|
24
|
+
readonly verifiedGlyphTables?: ReadonlyMap<string, VerifiedGlyphTableSource>;
|
|
22
25
|
}
|
|
23
26
|
interface FontResolverService {
|
|
24
27
|
readonly metrics: FontMetricsPort;
|
package/dist/font-read.js
CHANGED
|
@@ -10,6 +10,7 @@ import { parseToUnicodeCMap } from "./cmap.js";
|
|
|
10
10
|
import { symbolGlyphName, zapfDingbatsGlyphName } from "./encoding-symbol-tables.js";
|
|
11
11
|
import { resolveStandardFont } from "./fonts.js";
|
|
12
12
|
import { symbolFontOf, withSymbolFontCharacters } from "./symbol-font-private-use.js";
|
|
13
|
+
import { VERIFIED_GLYPH_FAMILIES, programDigest, verifiedGlyphTableOfDigest } from "./verified-glyph-tables.js";
|
|
13
14
|
//#region src/font-read.ts
|
|
14
15
|
const BITS_PER_BYTE = 8;
|
|
15
16
|
const SYMBOLIC_FLAG_BIT = 4;
|
|
@@ -50,6 +51,33 @@ function lazyFontProgram(descriptor, baseFont, context) {
|
|
|
50
51
|
return read.encoding;
|
|
51
52
|
};
|
|
52
53
|
}
|
|
54
|
+
function lazyVerifiedGlyphTable(descriptor, family, context) {
|
|
55
|
+
let read;
|
|
56
|
+
return () => {
|
|
57
|
+
if (descriptor === void 0 || !VERIFIED_GLYPH_FAMILIES.has(family)) return;
|
|
58
|
+
read ??= { table: verifiedGlyphTableOfProgram(descriptor, family, context) };
|
|
59
|
+
return read.table;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const PROGRAM_DIGESTS = /* @__PURE__ */ new WeakMap();
|
|
63
|
+
function digestOfFontStream(stream, context) {
|
|
64
|
+
let digest = PROGRAM_DIGESTS.get(stream);
|
|
65
|
+
if (digest === void 0) {
|
|
66
|
+
digest = programDigest(decodeStream(stream.raw, stream.dict, context.sink).bytes);
|
|
67
|
+
PROGRAM_DIGESTS.set(stream, digest);
|
|
68
|
+
}
|
|
69
|
+
return digest;
|
|
70
|
+
}
|
|
71
|
+
function verifiedGlyphTableOfProgram(descriptor, family, context) {
|
|
72
|
+
for (const key of [
|
|
73
|
+
"FontFile3",
|
|
74
|
+
"FontFile2",
|
|
75
|
+
"FontFile"
|
|
76
|
+
]) {
|
|
77
|
+
const stream = context.resolver.resolve(dictGet(descriptor, key));
|
|
78
|
+
if (stream?.kind === "stream") return verifiedGlyphTableOfDigest(family, digestOfFontStream(stream, context), context.verifiedGlyphTables);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
53
81
|
function readDifferencesMap(differences) {
|
|
54
82
|
const map = /* @__PURE__ */ new Map();
|
|
55
83
|
if (differences === void 0) return map;
|
|
@@ -86,6 +114,7 @@ function buildSimpleFont(fontDict, context) {
|
|
|
86
114
|
const symbolic = styleFlags.symbolic ?? false;
|
|
87
115
|
const builtinGlyphName = builtinSymbolGlyphNameLookup(baseFamily);
|
|
88
116
|
const symbolFont = symbolFontOf(baseFamily);
|
|
117
|
+
const verifiedGlyphs = lazyVerifiedGlyphTable(descriptor, baseFamily, context);
|
|
89
118
|
const widthsArr = resolvedArray(dictGet(fontDict, "Widths"), context);
|
|
90
119
|
const firstChar = asNumber(dictGet(fontDict, "FirstChar")) ?? 0;
|
|
91
120
|
const missingWidth = (descriptor !== void 0 ? asNumber(dictGet(descriptor, "MissingWidth")) : void 0) ?? 0;
|
|
@@ -170,6 +199,12 @@ function buildSimpleFont(fontDict, context) {
|
|
|
170
199
|
let out = "";
|
|
171
200
|
let unmapped = 0;
|
|
172
201
|
for (const code of codes) {
|
|
202
|
+
const glyphName = differencesMap.get(code) ?? namedBaseGlyphName?.(code);
|
|
203
|
+
const verified = glyphName === void 0 ? void 0 : verifiedGlyphs()?.glyphs.get(glyphName);
|
|
204
|
+
if (verified !== void 0) {
|
|
205
|
+
out += verified;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
173
208
|
const viaToUnicode = toUnicode?.lookup(code);
|
|
174
209
|
if (viaToUnicode !== void 0) {
|
|
175
210
|
out += withSymbolFontCharacters(symbolFont, viaToUnicode);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/verified-glyph-tables.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The SHA-256 of a decoded font program as lower-case hex, the key the verified subsets are filed under.
|
|
4
|
+
* @param bytes - The decoded bytes of the embedded font program.
|
|
5
|
+
* @returns The digest.
|
|
6
|
+
*/
|
|
7
|
+
declare function programDigest(bytes: Uint8Array<ArrayBuffer>): string;
|
|
8
|
+
/** One verified subset: the font family its `/BaseFont` names (the subset tag taken off) and the character each listed glyph draws, by the program's own glyph name. */
|
|
9
|
+
interface VerifiedGlyphTable {
|
|
10
|
+
readonly family: string;
|
|
11
|
+
readonly glyphs: ReadonlyMap<string, string>;
|
|
12
|
+
}
|
|
13
|
+
interface VerifiedGlyphTableSource {
|
|
14
|
+
readonly family: string;
|
|
15
|
+
readonly glyphs: Readonly<Record<string, string>>;
|
|
16
|
+
}
|
|
17
|
+
/** The subsets checked so far, by the SHA-256 of the decoded font program. */
|
|
18
|
+
declare const VERIFIED_SOURCES: ReadonlyMap<string, VerifiedGlyphTableSource>;
|
|
19
|
+
/** The font families some verified subset belongs to: a font of any other family is not hashed. */
|
|
20
|
+
declare const VERIFIED_GLYPH_FAMILIES: ReadonlySet<string>;
|
|
21
|
+
/**
|
|
22
|
+
* The verified table for an embedded font program given its digest, or `undefined` for any program that is not exactly one that was checked.
|
|
23
|
+
* @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.
|
|
24
|
+
* @param digest - The SHA-256 of the decoded font program (`programDigest`).
|
|
25
|
+
* @param tables - The verified subsets to look in, by program SHA-256; the checked ones unless a test supplies its own.
|
|
26
|
+
* @returns The table for that subset, or `undefined`.
|
|
27
|
+
*/
|
|
28
|
+
declare function verifiedGlyphTableOfDigest(family: string, digest: string, tables?: ReadonlyMap<string, VerifiedGlyphTableSource>): VerifiedGlyphTable | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The verified table for an embedded font program, or `undefined` for any program that is not exactly one that was checked.
|
|
31
|
+
* @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.
|
|
32
|
+
* @param program - The decoded bytes of the embedded font program.
|
|
33
|
+
* @param tables - The verified subsets to look in, by program SHA-256; the checked ones unless a test supplies its own.
|
|
34
|
+
* @returns The table for that subset, or `undefined`.
|
|
35
|
+
*/
|
|
36
|
+
declare function verifiedGlyphTableFor(family: string, program: Uint8Array<ArrayBuffer>, tables?: ReadonlyMap<string, VerifiedGlyphTableSource>): VerifiedGlyphTable | undefined;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { programDigest as a, VerifiedGlyphTableSource as i, VERIFIED_SOURCES as n, verifiedGlyphTableFor as o, VerifiedGlyphTable as r, verifiedGlyphTableOfDigest as s, VERIFIED_GLYPH_FAMILIES as t };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/verified-glyph-tables.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The SHA-256 of a decoded font program as lower-case hex, the key the verified subsets are filed under.
|
|
4
|
+
* @param bytes - The decoded bytes of the embedded font program.
|
|
5
|
+
* @returns The digest.
|
|
6
|
+
*/
|
|
7
|
+
declare function programDigest(bytes: Uint8Array<ArrayBuffer>): string;
|
|
8
|
+
/** One verified subset: the font family its `/BaseFont` names (the subset tag taken off) and the character each listed glyph draws, by the program's own glyph name. */
|
|
9
|
+
interface VerifiedGlyphTable {
|
|
10
|
+
readonly family: string;
|
|
11
|
+
readonly glyphs: ReadonlyMap<string, string>;
|
|
12
|
+
}
|
|
13
|
+
interface VerifiedGlyphTableSource {
|
|
14
|
+
readonly family: string;
|
|
15
|
+
readonly glyphs: Readonly<Record<string, string>>;
|
|
16
|
+
}
|
|
17
|
+
/** The subsets checked so far, by the SHA-256 of the decoded font program. */
|
|
18
|
+
declare const VERIFIED_SOURCES: ReadonlyMap<string, VerifiedGlyphTableSource>;
|
|
19
|
+
/** The font families some verified subset belongs to: a font of any other family is not hashed. */
|
|
20
|
+
declare const VERIFIED_GLYPH_FAMILIES: ReadonlySet<string>;
|
|
21
|
+
/**
|
|
22
|
+
* The verified table for an embedded font program given its digest, or `undefined` for any program that is not exactly one that was checked.
|
|
23
|
+
* @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.
|
|
24
|
+
* @param digest - The SHA-256 of the decoded font program (`programDigest`).
|
|
25
|
+
* @param tables - The verified subsets to look in, by program SHA-256; the checked ones unless a test supplies its own.
|
|
26
|
+
* @returns The table for that subset, or `undefined`.
|
|
27
|
+
*/
|
|
28
|
+
declare function verifiedGlyphTableOfDigest(family: string, digest: string, tables?: ReadonlyMap<string, VerifiedGlyphTableSource>): VerifiedGlyphTable | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The verified table for an embedded font program, or `undefined` for any program that is not exactly one that was checked.
|
|
31
|
+
* @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.
|
|
32
|
+
* @param program - The decoded bytes of the embedded font program.
|
|
33
|
+
* @param tables - The verified subsets to look in, by program SHA-256; the checked ones unless a test supplies its own.
|
|
34
|
+
* @returns The table for that subset, or `undefined`.
|
|
35
|
+
*/
|
|
36
|
+
declare function verifiedGlyphTableFor(family: string, program: Uint8Array<ArrayBuffer>, tables?: ReadonlyMap<string, VerifiedGlyphTableSource>): VerifiedGlyphTable | undefined;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { programDigest as a, VerifiedGlyphTableSource as i, VERIFIED_SOURCES as n, verifiedGlyphTableFor as o, VerifiedGlyphTable as r, verifiedGlyphTableOfDigest as s, VERIFIED_GLYPH_FAMILIES as t };
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_crypto_sha2 = require("./crypto/sha2.cjs");
|
|
3
|
+
//#region src/verified-glyph-tables.ts
|
|
4
|
+
const HEX_RADIX = 16;
|
|
5
|
+
const HEX_DIGITS_PER_BYTE = 2;
|
|
6
|
+
/**
|
|
7
|
+
* The SHA-256 of a decoded font program as lower-case hex, the key the verified subsets are filed under.
|
|
8
|
+
* @param bytes - The decoded bytes of the embedded font program.
|
|
9
|
+
* @returns The digest.
|
|
10
|
+
*/
|
|
11
|
+
function programDigest(bytes) {
|
|
12
|
+
return Array.from(require_crypto_sha2.sha256(bytes), (byte) => byte.toString(HEX_RADIX).padStart(HEX_DIGITS_PER_BYTE, "0")).join("");
|
|
13
|
+
}
|
|
14
|
+
/** The subsets checked so far, by the SHA-256 of the decoded font program. */
|
|
15
|
+
const VERIFIED_SOURCES = /* @__PURE__ */ new Map([
|
|
16
|
+
["f483d278b1ade68af30ba62e57752933bccea6ee61d388fbf73ed2047feb620c", {
|
|
17
|
+
family: "AdvP4C4E74",
|
|
18
|
+
glyphs: {
|
|
19
|
+
onequarter: "=",
|
|
20
|
+
thorn: "+"
|
|
21
|
+
}
|
|
22
|
+
}],
|
|
23
|
+
["40b088a33057f42fdb763f1eb9e849574a925ce59e413a0e94617b3333b40056", {
|
|
24
|
+
family: "AdvMT_MI",
|
|
25
|
+
glyphs: {
|
|
26
|
+
C11: "α",
|
|
27
|
+
C12: "β",
|
|
28
|
+
C13: "γ",
|
|
29
|
+
C14: "δ",
|
|
30
|
+
C15: "ϵ",
|
|
31
|
+
C17: "η",
|
|
32
|
+
C18: "θ",
|
|
33
|
+
C20: "κ",
|
|
34
|
+
C21: "λ",
|
|
35
|
+
C22: "μ",
|
|
36
|
+
C23: "ν",
|
|
37
|
+
C25: "π",
|
|
38
|
+
C26: "ρ",
|
|
39
|
+
C27: "σ",
|
|
40
|
+
C28: "τ",
|
|
41
|
+
C30: "ϕ",
|
|
42
|
+
C31: "χ",
|
|
43
|
+
at: "∂",
|
|
44
|
+
colon: ".",
|
|
45
|
+
equal: "/",
|
|
46
|
+
exclam: "ω",
|
|
47
|
+
greater: ">",
|
|
48
|
+
less: "<",
|
|
49
|
+
quotedbl: "ε",
|
|
50
|
+
semicolon: ","
|
|
51
|
+
}
|
|
52
|
+
}],
|
|
53
|
+
["99212d4f61280dcc8ca4377fca8259451eb05e0867a0017c0c41a521cd9fffac", {
|
|
54
|
+
family: "AdvMT_SY",
|
|
55
|
+
glyphs: {
|
|
56
|
+
C0: "−",
|
|
57
|
+
C1: "⋅",
|
|
58
|
+
C138: "]",
|
|
59
|
+
C14: "○",
|
|
60
|
+
C17: "≡",
|
|
61
|
+
C18: "⊆",
|
|
62
|
+
C2: "×",
|
|
63
|
+
C20: "≤",
|
|
64
|
+
C21: "≥",
|
|
65
|
+
C22: "≼",
|
|
66
|
+
C25: "≈",
|
|
67
|
+
C26: "⊂",
|
|
68
|
+
C27: "⊃",
|
|
69
|
+
C28: "≪",
|
|
70
|
+
C29: "≫",
|
|
71
|
+
C3: "∗",
|
|
72
|
+
C30: "≺",
|
|
73
|
+
C6: "±",
|
|
74
|
+
R: "ℛ",
|
|
75
|
+
Thorn: ")",
|
|
76
|
+
b: "⌊",
|
|
77
|
+
backslash: "∩",
|
|
78
|
+
bracketleft: "∪",
|
|
79
|
+
c: "⌋",
|
|
80
|
+
dollar: "↔",
|
|
81
|
+
eth: "(",
|
|
82
|
+
exclam: "→",
|
|
83
|
+
f: "{",
|
|
84
|
+
ff: "∠",
|
|
85
|
+
ffi: "≅",
|
|
86
|
+
g: "}",
|
|
87
|
+
j: "|",
|
|
88
|
+
k: "‖",
|
|
89
|
+
numbersign: "↓",
|
|
90
|
+
one: "∞",
|
|
91
|
+
onehalf: "[",
|
|
92
|
+
onequarter: "=",
|
|
93
|
+
p: "√",
|
|
94
|
+
parenright: "⇒",
|
|
95
|
+
quoteright: "≃",
|
|
96
|
+
r: "∇",
|
|
97
|
+
six: "/",
|
|
98
|
+
thorn: "+",
|
|
99
|
+
two: "∈",
|
|
100
|
+
zero: "′"
|
|
101
|
+
}
|
|
102
|
+
}],
|
|
103
|
+
["53ea45831e6c9133d4bb030d84cc8888bfa065dc98a66b9229b2b578f7a2f615", {
|
|
104
|
+
family: "AdvP4C4E46",
|
|
105
|
+
glyphs: {
|
|
106
|
+
C0: "(",
|
|
107
|
+
C1: ")",
|
|
108
|
+
C16: "(",
|
|
109
|
+
C17: ")",
|
|
110
|
+
C18: "(",
|
|
111
|
+
C19: ")",
|
|
112
|
+
p: "√",
|
|
113
|
+
q: "√",
|
|
114
|
+
r: "√",
|
|
115
|
+
s: "√"
|
|
116
|
+
}
|
|
117
|
+
}],
|
|
118
|
+
["6071bcddbb9aa9d41a695f93ec76b9aacd2fee29325cc5a75e05ec39cbe419ac", {
|
|
119
|
+
family: "AdvP4C4E46",
|
|
120
|
+
glyphs: {
|
|
121
|
+
C0: "(",
|
|
122
|
+
C1: ")",
|
|
123
|
+
C16: "(",
|
|
124
|
+
C17: ")",
|
|
125
|
+
C18: "(",
|
|
126
|
+
C19: ")",
|
|
127
|
+
p: "√",
|
|
128
|
+
r: "√"
|
|
129
|
+
}
|
|
130
|
+
}],
|
|
131
|
+
["60efa155cc8d0a1bbe67f3926b42c856e503074caff150fd2ff6075f0b723ef2", {
|
|
132
|
+
family: "AdvP4C4E46",
|
|
133
|
+
glyphs: {
|
|
134
|
+
C0: "(",
|
|
135
|
+
C1: ")",
|
|
136
|
+
C16: "(",
|
|
137
|
+
C17: ")",
|
|
138
|
+
C18: "(",
|
|
139
|
+
C19: ")",
|
|
140
|
+
C20: "[",
|
|
141
|
+
C21: "]",
|
|
142
|
+
C26: "{",
|
|
143
|
+
C27: "}",
|
|
144
|
+
Eth: "∫",
|
|
145
|
+
P: "∑",
|
|
146
|
+
X: "∑",
|
|
147
|
+
asciicircum: "⋀",
|
|
148
|
+
backslash: "⋂",
|
|
149
|
+
eth: "∫",
|
|
150
|
+
exclam: ")",
|
|
151
|
+
five: "⎦",
|
|
152
|
+
four: "⎣",
|
|
153
|
+
h: "[",
|
|
154
|
+
i: "]",
|
|
155
|
+
numbersign: "]",
|
|
156
|
+
p: "√",
|
|
157
|
+
parenleft: "{",
|
|
158
|
+
q: "√",
|
|
159
|
+
quotedbl: "[",
|
|
160
|
+
r: "√",
|
|
161
|
+
s: "√",
|
|
162
|
+
space: "(",
|
|
163
|
+
three: "⎤",
|
|
164
|
+
two: "⎡"
|
|
165
|
+
}
|
|
166
|
+
}],
|
|
167
|
+
["a8442ad73af43eb9abec5cb790fe053953caf2cba069038689c1091a8bf1da57", {
|
|
168
|
+
family: "AdvP4C4E46",
|
|
169
|
+
glyphs: {
|
|
170
|
+
C0: "(",
|
|
171
|
+
C1: ")",
|
|
172
|
+
C16: "(",
|
|
173
|
+
C17: ")",
|
|
174
|
+
C18: "(",
|
|
175
|
+
C19: ")",
|
|
176
|
+
C20: "[",
|
|
177
|
+
C21: "]",
|
|
178
|
+
C26: "{",
|
|
179
|
+
C27: "}",
|
|
180
|
+
Eth: "∫",
|
|
181
|
+
P: "∑",
|
|
182
|
+
eth: "∫",
|
|
183
|
+
five: "⎦",
|
|
184
|
+
four: "⎣",
|
|
185
|
+
h: "[",
|
|
186
|
+
i: "]",
|
|
187
|
+
p: "√",
|
|
188
|
+
q: "√",
|
|
189
|
+
r: "√",
|
|
190
|
+
three: "⎤",
|
|
191
|
+
two: "⎡"
|
|
192
|
+
}
|
|
193
|
+
}],
|
|
194
|
+
["f2c12f17afd97014ccf6002befb9a7fa5c9156788bb9a616a5f9d31f8b5aaedd", {
|
|
195
|
+
family: "AdvP4C4E46",
|
|
196
|
+
glyphs: {
|
|
197
|
+
C16: "(",
|
|
198
|
+
C17: ")",
|
|
199
|
+
C18: "(",
|
|
200
|
+
C19: ")",
|
|
201
|
+
C20: "[",
|
|
202
|
+
C21: "]",
|
|
203
|
+
exclam: ")",
|
|
204
|
+
five: "⎦",
|
|
205
|
+
four: "⎣",
|
|
206
|
+
h: "[",
|
|
207
|
+
i: "]",
|
|
208
|
+
p: "√",
|
|
209
|
+
q: "√",
|
|
210
|
+
r: "√",
|
|
211
|
+
space: "(",
|
|
212
|
+
three: "⎤",
|
|
213
|
+
two: "⎡"
|
|
214
|
+
}
|
|
215
|
+
}],
|
|
216
|
+
["93463c42e9491b79f82f761b522ae2de72b6217efccd186930df7237ef8002ef", {
|
|
217
|
+
family: "AdvP4C4E51",
|
|
218
|
+
glyphs: {
|
|
219
|
+
colon: ".",
|
|
220
|
+
equal: "/",
|
|
221
|
+
greater: ">",
|
|
222
|
+
less: "<",
|
|
223
|
+
semicolon: ","
|
|
224
|
+
}
|
|
225
|
+
}],
|
|
226
|
+
["967c167a737966cddc29a62e6f0601efc797d1f9453d0f3df558306b2d8b91e2", {
|
|
227
|
+
family: "AdvP4C4E59",
|
|
228
|
+
glyphs: {
|
|
229
|
+
C1: "Δ",
|
|
230
|
+
C10: "Ω"
|
|
231
|
+
}
|
|
232
|
+
}],
|
|
233
|
+
["38c8aa8ccee56512b9816a6c93c2e2b166166b672560b5f827eef19c43626bd3", {
|
|
234
|
+
family: "AdvP4C4E74",
|
|
235
|
+
glyphs: {
|
|
236
|
+
C0: "−",
|
|
237
|
+
C14: "○",
|
|
238
|
+
C2: "×",
|
|
239
|
+
C20: "≤",
|
|
240
|
+
C21: "≥",
|
|
241
|
+
C3: "∗",
|
|
242
|
+
C6: "±",
|
|
243
|
+
Thorn: ")",
|
|
244
|
+
eth: "(",
|
|
245
|
+
onequarter: "=",
|
|
246
|
+
p: "√",
|
|
247
|
+
slash: "∝",
|
|
248
|
+
thorn: "+",
|
|
249
|
+
zero: "′"
|
|
250
|
+
}
|
|
251
|
+
}],
|
|
252
|
+
["4061cae07e31ac6441fef12114942a58d0bae5f64a0789932ee703654990a769", {
|
|
253
|
+
family: "AdvP4C4E74",
|
|
254
|
+
glyphs: {
|
|
255
|
+
C0: "−",
|
|
256
|
+
C1: "⋅",
|
|
257
|
+
C138: "]",
|
|
258
|
+
C14: "○",
|
|
259
|
+
C2: "×",
|
|
260
|
+
C20: "≤",
|
|
261
|
+
C21: "≥",
|
|
262
|
+
C6: "±",
|
|
263
|
+
C8: "⊕",
|
|
264
|
+
Thorn: ")",
|
|
265
|
+
eth: "(",
|
|
266
|
+
f: "{",
|
|
267
|
+
ff: "∠",
|
|
268
|
+
g: "}",
|
|
269
|
+
j: "|",
|
|
270
|
+
onehalf: "[",
|
|
271
|
+
onequarter: "=",
|
|
272
|
+
p: "√",
|
|
273
|
+
parenright: "⇒",
|
|
274
|
+
slash: "∝",
|
|
275
|
+
thorn: "+",
|
|
276
|
+
zero: "′"
|
|
277
|
+
}
|
|
278
|
+
}],
|
|
279
|
+
["4983c0bc19d073482c226511409622f6009444f10660bd4d6fd146e876af1eb0", {
|
|
280
|
+
family: "AdvP4C4E74",
|
|
281
|
+
glyphs: {
|
|
282
|
+
C0: "−",
|
|
283
|
+
C1: "⋅",
|
|
284
|
+
C138: "]",
|
|
285
|
+
C14: "○",
|
|
286
|
+
C2: "×",
|
|
287
|
+
C20: "≤",
|
|
288
|
+
C3: "∗",
|
|
289
|
+
C6: "±",
|
|
290
|
+
Thorn: ")",
|
|
291
|
+
eth: "(",
|
|
292
|
+
f: "{",
|
|
293
|
+
ff: "∠",
|
|
294
|
+
g: "}",
|
|
295
|
+
numbersign: "↓",
|
|
296
|
+
onehalf: "[",
|
|
297
|
+
onequarter: "=",
|
|
298
|
+
p: "√",
|
|
299
|
+
slash: "∝",
|
|
300
|
+
thorn: "+"
|
|
301
|
+
}
|
|
302
|
+
}],
|
|
303
|
+
["ccf77c4a71142b8025af5b751a4cc473204521ea2eddcf1d91f1713182c5aecf", {
|
|
304
|
+
family: "AdvP4C4E74",
|
|
305
|
+
glyphs: {
|
|
306
|
+
C0: "−",
|
|
307
|
+
C1: "⋅",
|
|
308
|
+
C138: "]",
|
|
309
|
+
C14: "○",
|
|
310
|
+
C15: "●",
|
|
311
|
+
C2: "×",
|
|
312
|
+
C20: "≤",
|
|
313
|
+
C21: "≥",
|
|
314
|
+
C24: "∼",
|
|
315
|
+
C25: "≈",
|
|
316
|
+
C29: "≫",
|
|
317
|
+
C3: "∗",
|
|
318
|
+
C6: "±",
|
|
319
|
+
Thorn: ")",
|
|
320
|
+
b: "⌊",
|
|
321
|
+
c: "⌋",
|
|
322
|
+
eth: "(",
|
|
323
|
+
exclam: "→",
|
|
324
|
+
f: "{",
|
|
325
|
+
ff: "∠",
|
|
326
|
+
ffi: "≅",
|
|
327
|
+
g: "}",
|
|
328
|
+
j: "|",
|
|
329
|
+
one: "∞",
|
|
330
|
+
onehalf: "[",
|
|
331
|
+
onequarter: "=",
|
|
332
|
+
p: "√",
|
|
333
|
+
parenright: "⇒",
|
|
334
|
+
r: "∇",
|
|
335
|
+
six: "/",
|
|
336
|
+
slash: "∝",
|
|
337
|
+
space: "←",
|
|
338
|
+
thorn: "+",
|
|
339
|
+
two: "∈",
|
|
340
|
+
zero: "′"
|
|
341
|
+
}
|
|
342
|
+
}],
|
|
343
|
+
["dc3008dbca19a91b63116bcfed491a45776faffadc2c8063b5367c71bf1657d1", {
|
|
344
|
+
family: "AdvP4C4E74",
|
|
345
|
+
glyphs: {
|
|
346
|
+
C0: "−",
|
|
347
|
+
C138: "]",
|
|
348
|
+
C14: "○",
|
|
349
|
+
C2: "×",
|
|
350
|
+
C20: "≤",
|
|
351
|
+
C21: "≥",
|
|
352
|
+
C4: "÷",
|
|
353
|
+
C6: "±",
|
|
354
|
+
Thorn: ")",
|
|
355
|
+
eth: "(",
|
|
356
|
+
onehalf: "[",
|
|
357
|
+
onequarter: "=",
|
|
358
|
+
p: "√",
|
|
359
|
+
slash: "∝",
|
|
360
|
+
thorn: "+"
|
|
361
|
+
}
|
|
362
|
+
}]
|
|
363
|
+
]);
|
|
364
|
+
function tableOf(source) {
|
|
365
|
+
return {
|
|
366
|
+
family: source.family,
|
|
367
|
+
glyphs: new Map(Object.entries(source.glyphs))
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
/** The font families some verified subset belongs to: a font of any other family is not hashed. */
|
|
371
|
+
const VERIFIED_GLYPH_FAMILIES = new Set([...VERIFIED_SOURCES.values()].map((source) => source.family));
|
|
372
|
+
/**
|
|
373
|
+
* The verified table for an embedded font program given its digest, or `undefined` for any program that is not exactly one that was checked.
|
|
374
|
+
* @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.
|
|
375
|
+
* @param digest - The SHA-256 of the decoded font program (`programDigest`).
|
|
376
|
+
* @param tables - The verified subsets to look in, by program SHA-256; the checked ones unless a test supplies its own.
|
|
377
|
+
* @returns The table for that subset, or `undefined`.
|
|
378
|
+
*/
|
|
379
|
+
function verifiedGlyphTableOfDigest(family, digest, tables = VERIFIED_SOURCES) {
|
|
380
|
+
const source = tables.get(digest);
|
|
381
|
+
return source?.family === family ? tableOf(source) : void 0;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* The verified table for an embedded font program, or `undefined` for any program that is not exactly one that was checked.
|
|
385
|
+
* @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.
|
|
386
|
+
* @param program - The decoded bytes of the embedded font program.
|
|
387
|
+
* @param tables - The verified subsets to look in, by program SHA-256; the checked ones unless a test supplies its own.
|
|
388
|
+
* @returns The table for that subset, or `undefined`.
|
|
389
|
+
*/
|
|
390
|
+
function verifiedGlyphTableFor(family, program, tables = VERIFIED_SOURCES) {
|
|
391
|
+
return verifiedGlyphTableOfDigest(family, programDigest(program), tables);
|
|
392
|
+
}
|
|
393
|
+
//#endregion
|
|
394
|
+
exports.VERIFIED_GLYPH_FAMILIES = VERIFIED_GLYPH_FAMILIES;
|
|
395
|
+
exports.VERIFIED_SOURCES = VERIFIED_SOURCES;
|
|
396
|
+
exports.programDigest = programDigest;
|
|
397
|
+
exports.verifiedGlyphTableFor = verifiedGlyphTableFor;
|
|
398
|
+
exports.verifiedGlyphTableOfDigest = verifiedGlyphTableOfDigest;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as programDigest, i as VerifiedGlyphTableSource, n as VERIFIED_SOURCES, o as verifiedGlyphTableFor, r as VerifiedGlyphTable, s as verifiedGlyphTableOfDigest, t as VERIFIED_GLYPH_FAMILIES } from "./verified-glyph-tables-B_ZoMhyT.cjs";
|
|
2
|
+
export { VERIFIED_GLYPH_FAMILIES, VERIFIED_SOURCES, VerifiedGlyphTable, VerifiedGlyphTableSource, programDigest, verifiedGlyphTableFor, verifiedGlyphTableOfDigest };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as programDigest, i as VerifiedGlyphTableSource, n as VERIFIED_SOURCES, o as verifiedGlyphTableFor, r as VerifiedGlyphTable, s as verifiedGlyphTableOfDigest, t as VERIFIED_GLYPH_FAMILIES } from "./verified-glyph-tables-B_ZoMhyT.js";
|
|
2
|
+
export { VERIFIED_GLYPH_FAMILIES, VERIFIED_SOURCES, VerifiedGlyphTable, VerifiedGlyphTableSource, programDigest, verifiedGlyphTableFor, verifiedGlyphTableOfDigest };
|
|
@@ -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": {
|