pdf-codec 1.3.0 → 1.4.0
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 +38 -0
- package/dist/afm-widths-BoeTOK2r.cjs +826 -0
- package/dist/afm-widths-Dxucrg7D.js +779 -0
- package/dist/afm-widths-DyDq56Ph.d.cts +19 -0
- package/dist/afm-widths-DyDq56Ph.d.ts +19 -0
- package/dist/afm-widths.cjs +4 -0
- package/dist/afm-widths.d.cts +2 -0
- package/dist/afm-widths.d.ts +2 -0
- package/dist/afm-widths.js +2 -0
- package/dist/assets/stix-two-math-font.cjs +5 -0
- package/dist/assets/stix-two-math-font.d.cts +4 -0
- package/dist/assets/stix-two-math-font.d.ts +4 -0
- package/dist/assets/stix-two-math-font.js +4 -0
- package/dist/bytes/crc32.cjs +21 -0
- package/dist/bytes/crc32.d.cts +4 -0
- package/dist/bytes/crc32.d.ts +4 -0
- package/dist/bytes/crc32.js +20 -0
- package/dist/bytes/flate.cjs +53 -0
- package/dist/bytes/flate.d.cts +12 -0
- package/dist/bytes/flate.d.ts +12 -0
- package/dist/bytes/flate.js +49 -0
- package/dist/bytes/reader.cjs +60 -0
- package/dist/bytes/reader.d.cts +20 -0
- package/dist/bytes/reader.d.ts +20 -0
- package/dist/bytes/reader.js +58 -0
- package/dist/bytes/writer.cjs +37 -0
- package/dist/bytes/writer.d.cts +13 -0
- package/dist/bytes/writer.d.ts +13 -0
- package/dist/bytes/writer.js +35 -0
- package/dist/cmap.cjs +110 -0
- package/dist/cmap.d.cts +8 -0
- package/dist/cmap.d.ts +8 -0
- package/dist/cmap.js +109 -0
- package/dist/codec.cjs +34 -0
- package/dist/codec.d.cts +167 -0
- package/dist/codec.d.ts +167 -0
- package/dist/codec.js +32 -0
- package/dist/content-read.cjs +126 -0
- package/dist/content-read.d.cts +21 -0
- package/dist/content-read.d.ts +21 -0
- package/dist/content-read.js +125 -0
- package/dist/content-write.cjs +138 -0
- package/dist/content-write.d.cts +24 -0
- package/dist/content-write.d.ts +24 -0
- package/dist/content-write.js +137 -0
- package/dist/diagnostics.cjs +21 -0
- package/dist/diagnostics.d.cts +19 -0
- package/dist/diagnostics.d.ts +19 -0
- package/dist/diagnostics.js +18 -0
- package/dist/document.cjs +162 -0
- package/dist/document.d.cts +12 -0
- package/dist/document.d.ts +12 -0
- package/dist/document.js +161 -0
- package/dist/encoding.cjs +5 -0
- package/dist/encoding.d.cts +6 -0
- package/dist/encoding.d.ts +6 -0
- package/dist/encoding.js +2 -0
- package/dist/filters.cjs +223 -0
- package/dist/filters.d.cts +14 -0
- package/dist/filters.d.ts +14 -0
- package/dist/filters.js +218 -0
- package/dist/font-read.cjs +199 -0
- package/dist/font-read.d.cts +23 -0
- package/dist/font-read.d.ts +23 -0
- package/dist/font-read.js +198 -0
- package/dist/font-style.cjs +35 -0
- package/dist/font-style.d.cts +14 -0
- package/dist/font-style.d.ts +14 -0
- package/dist/font-style.js +34 -0
- package/dist/fonts.cjs +124 -0
- package/dist/fonts.d.cts +15 -0
- package/dist/fonts.d.ts +15 -0
- package/dist/fonts.js +122 -0
- package/dist/formula.cjs +0 -0
- package/dist/formula.d.cts +10 -0
- package/dist/formula.d.ts +10 -0
- package/dist/formula.js +0 -0
- package/dist/image/jpeg-info.cjs +71 -0
- package/dist/image/jpeg-info.d.cts +12 -0
- package/dist/image/jpeg-info.d.ts +12 -0
- package/dist/image/jpeg-info.js +70 -0
- package/dist/image/png-decode.cjs +181 -0
- package/dist/image/png-decode.d.cts +14 -0
- package/dist/image/png-decode.d.ts +14 -0
- package/dist/image/png-decode.js +180 -0
- package/dist/image/png-encode.cjs +64 -0
- package/dist/image/png-encode.d.cts +8 -0
- package/dist/image/png-encode.d.ts +8 -0
- package/dist/image/png-encode.js +63 -0
- package/dist/image/png-filter.cjs +95 -0
- package/dist/image/png-filter.d.cts +6 -0
- package/dist/image/png-filter.d.ts +6 -0
- package/dist/image/png-filter.js +93 -0
- package/dist/images-read.cjs +250 -0
- package/dist/images-read.d.cts +13 -0
- package/dist/images-read.d.ts +13 -0
- package/dist/images-read.js +249 -0
- package/dist/index.cjs +45 -5912
- package/dist/index.d.cts +21 -483
- package/dist/index.d.ts +21 -483
- package/dist/index.js +18 -5885
- package/dist/interpret.cjs +587 -0
- package/dist/interpret.d.cts +84 -0
- package/dist/interpret.d.ts +84 -0
- package/dist/interpret.js +586 -0
- package/dist/lexer.cjs +180 -0
- package/dist/lexer.d.cts +29 -0
- package/dist/lexer.d.ts +29 -0
- package/dist/lexer.js +179 -0
- package/dist/math-cmap.cjs +81 -0
- package/dist/math-cmap.d.cts +6 -0
- package/dist/math-cmap.d.ts +6 -0
- package/dist/math-cmap.js +80 -0
- package/dist/math-content-write.cjs +83 -0
- package/dist/math-content-write.d.cts +11 -0
- package/dist/math-content-write.d.ts +11 -0
- package/dist/math-content-write.js +81 -0
- package/dist/math-font-write.cjs +100 -0
- package/dist/math-font-write.d.cts +19 -0
- package/dist/math-font-write.d.ts +19 -0
- package/dist/math-font-write.js +99 -0
- package/dist/math-font.cjs +103 -0
- package/dist/math-font.d.cts +25 -0
- package/dist/math-font.d.ts +25 -0
- package/dist/math-font.js +102 -0
- package/dist/math-hmtx.cjs +17 -0
- package/dist/math-hmtx.d.cts +8 -0
- package/dist/math-hmtx.d.ts +8 -0
- package/dist/math-hmtx.js +16 -0
- package/dist/math-table.cjs +117 -0
- package/dist/math-table.d.cts +45 -0
- package/dist/math-table.d.ts +45 -0
- package/dist/math-table.js +116 -0
- package/dist/math-types-Ba8qAf1p.d.cts +82 -0
- package/dist/math-types-Ba8qAf1p.d.ts +82 -0
- package/dist/math-types.cjs +0 -0
- package/dist/math-types.d.cts +2 -0
- package/dist/math-types.d.ts +2 -0
- package/dist/math-types.js +0 -0
- package/dist/matrix-B3c2_a2f.d.cts +18 -0
- package/dist/matrix-B3c2_a2f.d.ts +18 -0
- package/dist/matrix.cjs +93 -0
- package/dist/matrix.d.cts +2 -0
- package/dist/matrix.d.ts +2 -0
- package/dist/matrix.js +83 -0
- package/dist/measure.cjs +54 -0
- package/dist/measure.d.cts +20 -0
- package/dist/measure.d.ts +20 -0
- package/dist/measure.js +53 -0
- package/dist/objects.cjs +100 -0
- package/dist/objects.d.cts +58 -0
- package/dist/objects.d.ts +58 -0
- package/dist/objects.js +84 -0
- package/dist/parse.cjs +230 -0
- package/dist/parse.d.cts +13 -0
- package/dist/parse.d.ts +13 -0
- package/dist/parse.js +228 -0
- package/dist/predictors.cjs +64 -0
- package/dist/predictors.d.cts +13 -0
- package/dist/predictors.d.ts +13 -0
- package/dist/predictors.js +62 -0
- package/dist/read.cjs +418 -0
- package/dist/read.d.cts +21 -0
- package/dist/read.d.ts +21 -0
- package/dist/read.js +413 -0
- package/dist/serialize.cjs +69 -0
- package/dist/serialize.d.cts +8 -0
- package/dist/serialize.d.ts +8 -0
- package/dist/serialize.js +66 -0
- package/dist/sfnt.cjs +52 -0
- package/dist/sfnt.d.cts +17 -0
- package/dist/sfnt.d.ts +17 -0
- package/dist/sfnt.js +46 -0
- package/dist/text-layout.cjs +224 -0
- package/dist/text-layout.d.cts +37 -0
- package/dist/text-layout.d.ts +37 -0
- package/dist/text-layout.js +222 -0
- package/dist/util/abort.cjs +7 -0
- package/dist/util/abort.d.cts +4 -0
- package/dist/util/abort.d.ts +4 -0
- package/dist/util/abort.js +6 -0
- package/dist/util/base64.cjs +48 -0
- package/dist/util/base64.d.cts +5 -0
- package/dist/util/base64.d.ts +5 -0
- package/dist/util/base64.js +46 -0
- package/dist/winansi.cjs +5 -0
- package/dist/winansi.d.cts +20 -0
- package/dist/winansi.d.ts +20 -0
- package/dist/winansi.js +2 -0
- package/dist/write.cjs +421 -0
- package/dist/write.d.cts +16 -0
- package/dist/write.d.ts +16 -0
- package/dist/write.js +419 -0
- package/dist/xref.cjs +325 -0
- package/dist/xref.d.cts +21 -0
- package/dist/xref.d.ts +21 -0
- package/dist/xref.js +324 -0
- package/package.json +9 -1
package/dist/lexer.cjs
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_bytes_reader = require("./bytes/reader.cjs");
|
|
3
|
+
//#region src/lexer.ts
|
|
4
|
+
const DELIMITER_BYTES = /* @__PURE__ */ new Set([
|
|
5
|
+
40,
|
|
6
|
+
41,
|
|
7
|
+
60,
|
|
8
|
+
62,
|
|
9
|
+
91,
|
|
10
|
+
93,
|
|
11
|
+
123,
|
|
12
|
+
125,
|
|
13
|
+
47,
|
|
14
|
+
37
|
|
15
|
+
]);
|
|
16
|
+
function isRegularByte(byte) {
|
|
17
|
+
return !require_bytes_reader.isAsciiWhitespace(byte) && !DELIMITER_BYTES.has(byte);
|
|
18
|
+
}
|
|
19
|
+
function isDigit(byte) {
|
|
20
|
+
return byte !== void 0 && byte >= 48 && byte <= 57;
|
|
21
|
+
}
|
|
22
|
+
function isHexDigit(byte) {
|
|
23
|
+
return byte !== void 0 && (byte >= 48 && byte <= 57 || byte >= 65 && byte <= 70 || byte >= 97 && byte <= 102);
|
|
24
|
+
}
|
|
25
|
+
function hexDigitValue(byte) {
|
|
26
|
+
if (byte >= 48 && byte <= 57) return byte - 48;
|
|
27
|
+
if (byte >= 65 && byte <= 70) return byte - 65 + 10;
|
|
28
|
+
return byte - 97 + 10;
|
|
29
|
+
}
|
|
30
|
+
function skipWhitespaceAndComments(reader) {
|
|
31
|
+
for (;;) {
|
|
32
|
+
reader.skipWhitespace();
|
|
33
|
+
if (reader.peek() !== 37) return;
|
|
34
|
+
while (!reader.atEnd() && reader.peek() !== 10 && reader.peek() !== 13) reader.next();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function readNumberToken(reader) {
|
|
38
|
+
const start = reader.offset;
|
|
39
|
+
if (reader.peek() === 43 || reader.peek() === 45) reader.next();
|
|
40
|
+
while (isDigit(reader.peek())) reader.next();
|
|
41
|
+
if (reader.peek() === 46) {
|
|
42
|
+
reader.next();
|
|
43
|
+
while (isDigit(reader.peek())) reader.next();
|
|
44
|
+
}
|
|
45
|
+
const text = new TextDecoder("latin1").decode(reader.slice(start, reader.offset));
|
|
46
|
+
return {
|
|
47
|
+
kind: "number",
|
|
48
|
+
value: Number(text)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function readNameToken(reader) {
|
|
52
|
+
reader.next();
|
|
53
|
+
const bytes = [];
|
|
54
|
+
for (;;) {
|
|
55
|
+
const byte = reader.peek();
|
|
56
|
+
if (byte === void 0 || !isRegularByte(byte)) break;
|
|
57
|
+
if (byte === 35 && isHexDigit(reader.peek(1)) && isHexDigit(reader.peek(2))) {
|
|
58
|
+
reader.next();
|
|
59
|
+
const hi = hexDigitValue(reader.next());
|
|
60
|
+
const lo = hexDigitValue(reader.next());
|
|
61
|
+
bytes.push(hi * 16 + lo);
|
|
62
|
+
} else bytes.push(reader.next());
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
kind: "name",
|
|
66
|
+
value: new TextDecoder("latin1").decode(new Uint8Array(bytes))
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function readLiteralStringToken(reader) {
|
|
70
|
+
reader.next();
|
|
71
|
+
const bytes = [];
|
|
72
|
+
let depth = 1;
|
|
73
|
+
for (;;) {
|
|
74
|
+
const byte = reader.next();
|
|
75
|
+
if (byte === void 0) break;
|
|
76
|
+
if (byte === 92) {
|
|
77
|
+
const esc = reader.next();
|
|
78
|
+
if (esc === void 0) break;
|
|
79
|
+
if (esc === 110) bytes.push(10);
|
|
80
|
+
else if (esc === 114) bytes.push(13);
|
|
81
|
+
else if (esc === 116) bytes.push(9);
|
|
82
|
+
else if (esc === 98) bytes.push(8);
|
|
83
|
+
else if (esc === 102) bytes.push(12);
|
|
84
|
+
else if (esc === 40 || esc === 41 || esc === 92) bytes.push(esc);
|
|
85
|
+
else if (esc === 13) {
|
|
86
|
+
if (reader.peek() === 10) reader.next();
|
|
87
|
+
} else if (esc === 10) {} else if (esc >= 48 && esc <= 55) {
|
|
88
|
+
let value = esc - 48;
|
|
89
|
+
for (let i = 0; i < 2 && reader.peek() !== void 0 && reader.peek() >= 48 && reader.peek() <= 55; i++) value = value * 8 + (reader.next() - 48);
|
|
90
|
+
bytes.push(value & 255);
|
|
91
|
+
} else bytes.push(esc);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (byte === 40) {
|
|
95
|
+
depth++;
|
|
96
|
+
bytes.push(byte);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (byte === 41) {
|
|
100
|
+
depth--;
|
|
101
|
+
if (depth === 0) break;
|
|
102
|
+
bytes.push(byte);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (byte === 13) {
|
|
106
|
+
if (reader.peek() === 10) reader.next();
|
|
107
|
+
bytes.push(10);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
bytes.push(byte);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
kind: "literalString",
|
|
114
|
+
value: new Uint8Array(bytes)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function readHexStringToken(reader) {
|
|
118
|
+
reader.next();
|
|
119
|
+
const digits = [];
|
|
120
|
+
for (;;) {
|
|
121
|
+
const byte = reader.next();
|
|
122
|
+
if (byte === void 0 || byte === 62) break;
|
|
123
|
+
if (isHexDigit(byte)) digits.push(hexDigitValue(byte));
|
|
124
|
+
}
|
|
125
|
+
if (digits.length % 2 === 1) digits.push(0);
|
|
126
|
+
const bytes = new Uint8Array(digits.length / 2);
|
|
127
|
+
for (let i = 0; i < bytes.length; i++) bytes[i] = digits[i * 2] * 16 + digits[i * 2 + 1];
|
|
128
|
+
return {
|
|
129
|
+
kind: "hexString",
|
|
130
|
+
value: bytes
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function readKeywordToken(reader) {
|
|
134
|
+
const start = reader.offset;
|
|
135
|
+
while (reader.peek() !== void 0 && isRegularByte(reader.peek())) reader.next();
|
|
136
|
+
return {
|
|
137
|
+
kind: "keyword",
|
|
138
|
+
value: new TextDecoder("latin1").decode(reader.slice(start, reader.offset))
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function nextToken(reader) {
|
|
142
|
+
skipWhitespaceAndComments(reader);
|
|
143
|
+
const byte = reader.peek();
|
|
144
|
+
if (byte === void 0) return;
|
|
145
|
+
if (byte === 47) return readNameToken(reader);
|
|
146
|
+
if (byte === 40) return readLiteralStringToken(reader);
|
|
147
|
+
if (byte === 60) {
|
|
148
|
+
if (reader.peek(1) === 60) {
|
|
149
|
+
reader.next();
|
|
150
|
+
reader.next();
|
|
151
|
+
return { kind: "dictStart" };
|
|
152
|
+
}
|
|
153
|
+
return readHexStringToken(reader);
|
|
154
|
+
}
|
|
155
|
+
if (byte === 62) {
|
|
156
|
+
if (reader.peek(1) === 62) {
|
|
157
|
+
reader.next();
|
|
158
|
+
reader.next();
|
|
159
|
+
return { kind: "dictEnd" };
|
|
160
|
+
}
|
|
161
|
+
reader.next();
|
|
162
|
+
return nextToken(reader);
|
|
163
|
+
}
|
|
164
|
+
if (byte === 91) {
|
|
165
|
+
reader.next();
|
|
166
|
+
return { kind: "arrayStart" };
|
|
167
|
+
}
|
|
168
|
+
if (byte === 93) {
|
|
169
|
+
reader.next();
|
|
170
|
+
return { kind: "arrayEnd" };
|
|
171
|
+
}
|
|
172
|
+
if (byte === 123 || byte === 125) {
|
|
173
|
+
reader.next();
|
|
174
|
+
return nextToken(reader);
|
|
175
|
+
}
|
|
176
|
+
if (byte === 43 || byte === 45 || byte === 46 || isDigit(byte)) return readNumberToken(reader);
|
|
177
|
+
return readKeywordToken(reader);
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
exports.nextToken = nextToken;
|
package/dist/lexer.d.cts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ByteReader } from "./bytes/reader.cjs";
|
|
2
|
+
//#region src/lexer.d.ts
|
|
3
|
+
type Token = {
|
|
4
|
+
readonly kind: 'number';
|
|
5
|
+
readonly value: number;
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'name';
|
|
8
|
+
readonly value: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'literalString';
|
|
11
|
+
readonly value: Uint8Array<ArrayBuffer>;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'hexString';
|
|
14
|
+
readonly value: Uint8Array<ArrayBuffer>;
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'arrayStart';
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: 'arrayEnd';
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'dictStart';
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: 'dictEnd';
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: 'keyword';
|
|
25
|
+
readonly value: string;
|
|
26
|
+
};
|
|
27
|
+
declare function nextToken(reader: ByteReader): Token | undefined;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { Token, nextToken };
|
package/dist/lexer.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ByteReader } from "./bytes/reader.js";
|
|
2
|
+
//#region src/lexer.d.ts
|
|
3
|
+
type Token = {
|
|
4
|
+
readonly kind: 'number';
|
|
5
|
+
readonly value: number;
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'name';
|
|
8
|
+
readonly value: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'literalString';
|
|
11
|
+
readonly value: Uint8Array<ArrayBuffer>;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'hexString';
|
|
14
|
+
readonly value: Uint8Array<ArrayBuffer>;
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'arrayStart';
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: 'arrayEnd';
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'dictStart';
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: 'dictEnd';
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: 'keyword';
|
|
25
|
+
readonly value: string;
|
|
26
|
+
};
|
|
27
|
+
declare function nextToken(reader: ByteReader): Token | undefined;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { Token, nextToken };
|
package/dist/lexer.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { isAsciiWhitespace } from "./bytes/reader.js";
|
|
2
|
+
//#region src/lexer.ts
|
|
3
|
+
const DELIMITER_BYTES = /* @__PURE__ */ new Set([
|
|
4
|
+
40,
|
|
5
|
+
41,
|
|
6
|
+
60,
|
|
7
|
+
62,
|
|
8
|
+
91,
|
|
9
|
+
93,
|
|
10
|
+
123,
|
|
11
|
+
125,
|
|
12
|
+
47,
|
|
13
|
+
37
|
|
14
|
+
]);
|
|
15
|
+
function isRegularByte(byte) {
|
|
16
|
+
return !isAsciiWhitespace(byte) && !DELIMITER_BYTES.has(byte);
|
|
17
|
+
}
|
|
18
|
+
function isDigit(byte) {
|
|
19
|
+
return byte !== void 0 && byte >= 48 && byte <= 57;
|
|
20
|
+
}
|
|
21
|
+
function isHexDigit(byte) {
|
|
22
|
+
return byte !== void 0 && (byte >= 48 && byte <= 57 || byte >= 65 && byte <= 70 || byte >= 97 && byte <= 102);
|
|
23
|
+
}
|
|
24
|
+
function hexDigitValue(byte) {
|
|
25
|
+
if (byte >= 48 && byte <= 57) return byte - 48;
|
|
26
|
+
if (byte >= 65 && byte <= 70) return byte - 65 + 10;
|
|
27
|
+
return byte - 97 + 10;
|
|
28
|
+
}
|
|
29
|
+
function skipWhitespaceAndComments(reader) {
|
|
30
|
+
for (;;) {
|
|
31
|
+
reader.skipWhitespace();
|
|
32
|
+
if (reader.peek() !== 37) return;
|
|
33
|
+
while (!reader.atEnd() && reader.peek() !== 10 && reader.peek() !== 13) reader.next();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function readNumberToken(reader) {
|
|
37
|
+
const start = reader.offset;
|
|
38
|
+
if (reader.peek() === 43 || reader.peek() === 45) reader.next();
|
|
39
|
+
while (isDigit(reader.peek())) reader.next();
|
|
40
|
+
if (reader.peek() === 46) {
|
|
41
|
+
reader.next();
|
|
42
|
+
while (isDigit(reader.peek())) reader.next();
|
|
43
|
+
}
|
|
44
|
+
const text = new TextDecoder("latin1").decode(reader.slice(start, reader.offset));
|
|
45
|
+
return {
|
|
46
|
+
kind: "number",
|
|
47
|
+
value: Number(text)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function readNameToken(reader) {
|
|
51
|
+
reader.next();
|
|
52
|
+
const bytes = [];
|
|
53
|
+
for (;;) {
|
|
54
|
+
const byte = reader.peek();
|
|
55
|
+
if (byte === void 0 || !isRegularByte(byte)) break;
|
|
56
|
+
if (byte === 35 && isHexDigit(reader.peek(1)) && isHexDigit(reader.peek(2))) {
|
|
57
|
+
reader.next();
|
|
58
|
+
const hi = hexDigitValue(reader.next());
|
|
59
|
+
const lo = hexDigitValue(reader.next());
|
|
60
|
+
bytes.push(hi * 16 + lo);
|
|
61
|
+
} else bytes.push(reader.next());
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
kind: "name",
|
|
65
|
+
value: new TextDecoder("latin1").decode(new Uint8Array(bytes))
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function readLiteralStringToken(reader) {
|
|
69
|
+
reader.next();
|
|
70
|
+
const bytes = [];
|
|
71
|
+
let depth = 1;
|
|
72
|
+
for (;;) {
|
|
73
|
+
const byte = reader.next();
|
|
74
|
+
if (byte === void 0) break;
|
|
75
|
+
if (byte === 92) {
|
|
76
|
+
const esc = reader.next();
|
|
77
|
+
if (esc === void 0) break;
|
|
78
|
+
if (esc === 110) bytes.push(10);
|
|
79
|
+
else if (esc === 114) bytes.push(13);
|
|
80
|
+
else if (esc === 116) bytes.push(9);
|
|
81
|
+
else if (esc === 98) bytes.push(8);
|
|
82
|
+
else if (esc === 102) bytes.push(12);
|
|
83
|
+
else if (esc === 40 || esc === 41 || esc === 92) bytes.push(esc);
|
|
84
|
+
else if (esc === 13) {
|
|
85
|
+
if (reader.peek() === 10) reader.next();
|
|
86
|
+
} else if (esc === 10) {} else if (esc >= 48 && esc <= 55) {
|
|
87
|
+
let value = esc - 48;
|
|
88
|
+
for (let i = 0; i < 2 && reader.peek() !== void 0 && reader.peek() >= 48 && reader.peek() <= 55; i++) value = value * 8 + (reader.next() - 48);
|
|
89
|
+
bytes.push(value & 255);
|
|
90
|
+
} else bytes.push(esc);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (byte === 40) {
|
|
94
|
+
depth++;
|
|
95
|
+
bytes.push(byte);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (byte === 41) {
|
|
99
|
+
depth--;
|
|
100
|
+
if (depth === 0) break;
|
|
101
|
+
bytes.push(byte);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (byte === 13) {
|
|
105
|
+
if (reader.peek() === 10) reader.next();
|
|
106
|
+
bytes.push(10);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
bytes.push(byte);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
kind: "literalString",
|
|
113
|
+
value: new Uint8Array(bytes)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function readHexStringToken(reader) {
|
|
117
|
+
reader.next();
|
|
118
|
+
const digits = [];
|
|
119
|
+
for (;;) {
|
|
120
|
+
const byte = reader.next();
|
|
121
|
+
if (byte === void 0 || byte === 62) break;
|
|
122
|
+
if (isHexDigit(byte)) digits.push(hexDigitValue(byte));
|
|
123
|
+
}
|
|
124
|
+
if (digits.length % 2 === 1) digits.push(0);
|
|
125
|
+
const bytes = new Uint8Array(digits.length / 2);
|
|
126
|
+
for (let i = 0; i < bytes.length; i++) bytes[i] = digits[i * 2] * 16 + digits[i * 2 + 1];
|
|
127
|
+
return {
|
|
128
|
+
kind: "hexString",
|
|
129
|
+
value: bytes
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function readKeywordToken(reader) {
|
|
133
|
+
const start = reader.offset;
|
|
134
|
+
while (reader.peek() !== void 0 && isRegularByte(reader.peek())) reader.next();
|
|
135
|
+
return {
|
|
136
|
+
kind: "keyword",
|
|
137
|
+
value: new TextDecoder("latin1").decode(reader.slice(start, reader.offset))
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function nextToken(reader) {
|
|
141
|
+
skipWhitespaceAndComments(reader);
|
|
142
|
+
const byte = reader.peek();
|
|
143
|
+
if (byte === void 0) return;
|
|
144
|
+
if (byte === 47) return readNameToken(reader);
|
|
145
|
+
if (byte === 40) return readLiteralStringToken(reader);
|
|
146
|
+
if (byte === 60) {
|
|
147
|
+
if (reader.peek(1) === 60) {
|
|
148
|
+
reader.next();
|
|
149
|
+
reader.next();
|
|
150
|
+
return { kind: "dictStart" };
|
|
151
|
+
}
|
|
152
|
+
return readHexStringToken(reader);
|
|
153
|
+
}
|
|
154
|
+
if (byte === 62) {
|
|
155
|
+
if (reader.peek(1) === 62) {
|
|
156
|
+
reader.next();
|
|
157
|
+
reader.next();
|
|
158
|
+
return { kind: "dictEnd" };
|
|
159
|
+
}
|
|
160
|
+
reader.next();
|
|
161
|
+
return nextToken(reader);
|
|
162
|
+
}
|
|
163
|
+
if (byte === 91) {
|
|
164
|
+
reader.next();
|
|
165
|
+
return { kind: "arrayStart" };
|
|
166
|
+
}
|
|
167
|
+
if (byte === 93) {
|
|
168
|
+
reader.next();
|
|
169
|
+
return { kind: "arrayEnd" };
|
|
170
|
+
}
|
|
171
|
+
if (byte === 123 || byte === 125) {
|
|
172
|
+
reader.next();
|
|
173
|
+
return nextToken(reader);
|
|
174
|
+
}
|
|
175
|
+
if (byte === 43 || byte === 45 || byte === 46 || isDigit(byte)) return readNumberToken(reader);
|
|
176
|
+
return readKeywordToken(reader);
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
export { nextToken };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_sfnt = require("./sfnt.cjs");
|
|
3
|
+
//#region src/math-cmap.ts
|
|
4
|
+
function parseFormat4(bytes, subtableOffset) {
|
|
5
|
+
const segCountX2 = require_sfnt.u16(bytes, subtableOffset + 6);
|
|
6
|
+
const segCount = segCountX2 / 2;
|
|
7
|
+
const endCodesOffset = subtableOffset + 14;
|
|
8
|
+
const startCodesOffset = endCodesOffset + segCountX2 + 2;
|
|
9
|
+
const idDeltasOffset = startCodesOffset + segCountX2;
|
|
10
|
+
const idRangeOffsetsOffset = idDeltasOffset + segCountX2;
|
|
11
|
+
const groups = [];
|
|
12
|
+
for (let i = 0; i < segCount; i++) {
|
|
13
|
+
const idRangeOffsetPos = idRangeOffsetsOffset + i * 2;
|
|
14
|
+
groups.push({
|
|
15
|
+
endCode: require_sfnt.u16(bytes, endCodesOffset + i * 2),
|
|
16
|
+
startCode: require_sfnt.u16(bytes, startCodesOffset + i * 2),
|
|
17
|
+
idDelta: (() => {
|
|
18
|
+
const raw = require_sfnt.u16(bytes, idDeltasOffset + i * 2);
|
|
19
|
+
return raw >= 32768 ? raw - 65536 : raw;
|
|
20
|
+
})(),
|
|
21
|
+
idRangeOffsetPos,
|
|
22
|
+
idRangeOffset: require_sfnt.u16(bytes, idRangeOffsetPos)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return (codePoint) => {
|
|
26
|
+
if (codePoint > 65535) return;
|
|
27
|
+
for (const group of groups) {
|
|
28
|
+
if (codePoint < group.startCode || codePoint > group.endCode) continue;
|
|
29
|
+
if (group.idRangeOffset === 0) return codePoint + group.idDelta & 65535;
|
|
30
|
+
const glyphIndexAddress = group.idRangeOffsetPos + group.idRangeOffset + (codePoint - group.startCode) * 2;
|
|
31
|
+
const glyphId = require_sfnt.u16(bytes, glyphIndexAddress);
|
|
32
|
+
return glyphId === 0 ? void 0 : glyphId + group.idDelta & 65535;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function parseFormat12(bytes, subtableOffset) {
|
|
37
|
+
const numGroups = require_sfnt.u32(bytes, subtableOffset + 12);
|
|
38
|
+
const groups = [];
|
|
39
|
+
for (let i = 0; i < numGroups; i++) {
|
|
40
|
+
const recordOffset = subtableOffset + 16 + i * 12;
|
|
41
|
+
groups.push({
|
|
42
|
+
startCharCode: require_sfnt.u32(bytes, recordOffset),
|
|
43
|
+
endCharCode: require_sfnt.u32(bytes, recordOffset + 4),
|
|
44
|
+
startGlyphId: require_sfnt.u32(bytes, recordOffset + 8)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return (codePoint) => {
|
|
48
|
+
for (const group of groups) if (codePoint >= group.startCharCode && codePoint <= group.endCharCode) return group.startGlyphId + (codePoint - group.startCharCode);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function buildCmapLookup(font) {
|
|
52
|
+
const cmapBytes = require_sfnt.sfntTableBytes(font, "cmap");
|
|
53
|
+
if (cmapBytes === void 0) throw new Error("math font has no cmap table");
|
|
54
|
+
const numTables = require_sfnt.u16(cmapBytes, 2);
|
|
55
|
+
const subtables = [];
|
|
56
|
+
for (let i = 0; i < numTables; i++) {
|
|
57
|
+
const recordOffset = 4 + i * 8;
|
|
58
|
+
const platformId = require_sfnt.u16(cmapBytes, recordOffset);
|
|
59
|
+
const encodingId = require_sfnt.u16(cmapBytes, recordOffset + 2);
|
|
60
|
+
const offset = require_sfnt.u32(cmapBytes, recordOffset + 4);
|
|
61
|
+
subtables.push({
|
|
62
|
+
platformId,
|
|
63
|
+
encodingId,
|
|
64
|
+
offset,
|
|
65
|
+
format: require_sfnt.u16(cmapBytes, offset)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const byPreference = (a) => {
|
|
69
|
+
if (a.format === 12 && a.platformId === 3 && a.encodingId === 10) return 0;
|
|
70
|
+
if (a.format === 12 && a.platformId === 0) return 1;
|
|
71
|
+
if (a.format === 12) return 2;
|
|
72
|
+
if (a.format === 4 && a.platformId === 3 && a.encodingId === 1) return 3;
|
|
73
|
+
if (a.format === 4) return 4;
|
|
74
|
+
return 5;
|
|
75
|
+
};
|
|
76
|
+
const best = subtables.filter((s) => s.format === 4 || s.format === 12).sort((a, b) => byPreference(a) - byPreference(b))[0];
|
|
77
|
+
if (best === void 0) throw new Error("math font cmap has no format 4 or format 12 subtable");
|
|
78
|
+
return best.format === 12 ? parseFormat12(cmapBytes, best.offset) : parseFormat4(cmapBytes, best.offset);
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
exports.buildCmapLookup = buildCmapLookup;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { sfntTableBytes, u16, u32 } from "./sfnt.js";
|
|
2
|
+
//#region src/math-cmap.ts
|
|
3
|
+
function parseFormat4(bytes, subtableOffset) {
|
|
4
|
+
const segCountX2 = u16(bytes, subtableOffset + 6);
|
|
5
|
+
const segCount = segCountX2 / 2;
|
|
6
|
+
const endCodesOffset = subtableOffset + 14;
|
|
7
|
+
const startCodesOffset = endCodesOffset + segCountX2 + 2;
|
|
8
|
+
const idDeltasOffset = startCodesOffset + segCountX2;
|
|
9
|
+
const idRangeOffsetsOffset = idDeltasOffset + segCountX2;
|
|
10
|
+
const groups = [];
|
|
11
|
+
for (let i = 0; i < segCount; i++) {
|
|
12
|
+
const idRangeOffsetPos = idRangeOffsetsOffset + i * 2;
|
|
13
|
+
groups.push({
|
|
14
|
+
endCode: u16(bytes, endCodesOffset + i * 2),
|
|
15
|
+
startCode: u16(bytes, startCodesOffset + i * 2),
|
|
16
|
+
idDelta: (() => {
|
|
17
|
+
const raw = u16(bytes, idDeltasOffset + i * 2);
|
|
18
|
+
return raw >= 32768 ? raw - 65536 : raw;
|
|
19
|
+
})(),
|
|
20
|
+
idRangeOffsetPos,
|
|
21
|
+
idRangeOffset: u16(bytes, idRangeOffsetPos)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return (codePoint) => {
|
|
25
|
+
if (codePoint > 65535) return;
|
|
26
|
+
for (const group of groups) {
|
|
27
|
+
if (codePoint < group.startCode || codePoint > group.endCode) continue;
|
|
28
|
+
if (group.idRangeOffset === 0) return codePoint + group.idDelta & 65535;
|
|
29
|
+
const glyphIndexAddress = group.idRangeOffsetPos + group.idRangeOffset + (codePoint - group.startCode) * 2;
|
|
30
|
+
const glyphId = u16(bytes, glyphIndexAddress);
|
|
31
|
+
return glyphId === 0 ? void 0 : glyphId + group.idDelta & 65535;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function parseFormat12(bytes, subtableOffset) {
|
|
36
|
+
const numGroups = u32(bytes, subtableOffset + 12);
|
|
37
|
+
const groups = [];
|
|
38
|
+
for (let i = 0; i < numGroups; i++) {
|
|
39
|
+
const recordOffset = subtableOffset + 16 + i * 12;
|
|
40
|
+
groups.push({
|
|
41
|
+
startCharCode: u32(bytes, recordOffset),
|
|
42
|
+
endCharCode: u32(bytes, recordOffset + 4),
|
|
43
|
+
startGlyphId: u32(bytes, recordOffset + 8)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return (codePoint) => {
|
|
47
|
+
for (const group of groups) if (codePoint >= group.startCharCode && codePoint <= group.endCharCode) return group.startGlyphId + (codePoint - group.startCharCode);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function buildCmapLookup(font) {
|
|
51
|
+
const cmapBytes = sfntTableBytes(font, "cmap");
|
|
52
|
+
if (cmapBytes === void 0) throw new Error("math font has no cmap table");
|
|
53
|
+
const numTables = u16(cmapBytes, 2);
|
|
54
|
+
const subtables = [];
|
|
55
|
+
for (let i = 0; i < numTables; i++) {
|
|
56
|
+
const recordOffset = 4 + i * 8;
|
|
57
|
+
const platformId = u16(cmapBytes, recordOffset);
|
|
58
|
+
const encodingId = u16(cmapBytes, recordOffset + 2);
|
|
59
|
+
const offset = u32(cmapBytes, recordOffset + 4);
|
|
60
|
+
subtables.push({
|
|
61
|
+
platformId,
|
|
62
|
+
encodingId,
|
|
63
|
+
offset,
|
|
64
|
+
format: u16(cmapBytes, offset)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const byPreference = (a) => {
|
|
68
|
+
if (a.format === 12 && a.platformId === 3 && a.encodingId === 10) return 0;
|
|
69
|
+
if (a.format === 12 && a.platformId === 0) return 1;
|
|
70
|
+
if (a.format === 12) return 2;
|
|
71
|
+
if (a.format === 4 && a.platformId === 3 && a.encodingId === 1) return 3;
|
|
72
|
+
if (a.format === 4) return 4;
|
|
73
|
+
return 5;
|
|
74
|
+
};
|
|
75
|
+
const best = subtables.filter((s) => s.format === 4 || s.format === 12).sort((a, b) => byPreference(a) - byPreference(b))[0];
|
|
76
|
+
if (best === void 0) throw new Error("math font cmap has no format 4 or format 12 subtable");
|
|
77
|
+
return best.format === 12 ? parseFormat12(cmapBytes, best.offset) : parseFormat4(cmapBytes, best.offset);
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { buildCmapLookup };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_bytes_writer = require("./bytes/writer.cjs");
|
|
3
|
+
const require_objects = require("./objects.cjs");
|
|
4
|
+
const require_serialize = require("./serialize.cjs");
|
|
5
|
+
//#region src/math-content-write.ts
|
|
6
|
+
function toPdfX(positioned, itemXPt) {
|
|
7
|
+
return positioned.xPt + itemXPt;
|
|
8
|
+
}
|
|
9
|
+
function toPdfY(positioned, itemYPt) {
|
|
10
|
+
return positioned.yPt + positioned.box.heightPt - itemYPt;
|
|
11
|
+
}
|
|
12
|
+
function writeRgbOperator(writer, color, operator) {
|
|
13
|
+
writer.writeAscii(`${require_serialize.formatNumber(color.r)} ${require_serialize.formatNumber(color.g)} ${require_serialize.formatNumber(color.b)} ${operator}\n`);
|
|
14
|
+
}
|
|
15
|
+
function encodeGlyphRunToCids(font, text) {
|
|
16
|
+
const gids = [];
|
|
17
|
+
for (const ch of text) {
|
|
18
|
+
const codePoint = ch.codePointAt(0);
|
|
19
|
+
if (codePoint === void 0) continue;
|
|
20
|
+
const glyphId = font.glyphId(codePoint);
|
|
21
|
+
if (glyphId !== void 0) gids.push(glyphId);
|
|
22
|
+
}
|
|
23
|
+
const bytes = new Uint8Array(gids.length * 2);
|
|
24
|
+
gids.forEach((gid, index) => {
|
|
25
|
+
bytes[index * 2] = gid >> 8 & 255;
|
|
26
|
+
bytes[index * 2 + 1] = gid & 255;
|
|
27
|
+
});
|
|
28
|
+
return bytes;
|
|
29
|
+
}
|
|
30
|
+
function writeGlyphRun(writer, positioned, item, ctx) {
|
|
31
|
+
const cidBytes = encodeGlyphRunToCids(ctx.font, item.text);
|
|
32
|
+
if (cidBytes.length === 0) return;
|
|
33
|
+
const x = toPdfX(positioned, item.xPt);
|
|
34
|
+
const y = toPdfY(positioned, item.yPt);
|
|
35
|
+
writer.writeAscii("BT\n");
|
|
36
|
+
writer.writeAscii(`/${ctx.resourceName} ${require_serialize.formatNumber(item.sizePt)} Tf\n`);
|
|
37
|
+
writeRgbOperator(writer, item.color, "rg");
|
|
38
|
+
writer.writeAscii(`1 0 0 1 ${require_serialize.formatNumber(x)} ${require_serialize.formatNumber(y)} Tm\n`);
|
|
39
|
+
require_serialize.writeObject(writer, require_objects.pdfHexString(cidBytes));
|
|
40
|
+
writer.writeAscii(" Tj\n");
|
|
41
|
+
writer.writeAscii("ET\n");
|
|
42
|
+
}
|
|
43
|
+
function writeRule(writer, positioned, item) {
|
|
44
|
+
const x = toPdfX(positioned, item.xPt);
|
|
45
|
+
const topY = toPdfY(positioned, item.yPt);
|
|
46
|
+
writeRgbOperator(writer, item.color, "rg");
|
|
47
|
+
writer.writeAscii(`${require_serialize.formatNumber(x)} ${require_serialize.formatNumber(topY - item.heightPt)} ${require_serialize.formatNumber(item.widthPt)} ${require_serialize.formatNumber(item.heightPt)} re\n`);
|
|
48
|
+
writer.writeAscii("f\n");
|
|
49
|
+
}
|
|
50
|
+
function writeStroke(writer, positioned, item) {
|
|
51
|
+
if (item.points.length < 2) return;
|
|
52
|
+
writeRgbOperator(writer, item.color, "RG");
|
|
53
|
+
writer.writeAscii(`${require_serialize.formatNumber(item.widthPt)} w\n`);
|
|
54
|
+
item.points.forEach((point, index) => {
|
|
55
|
+
const x = toPdfX(positioned, point.xPt);
|
|
56
|
+
const y = toPdfY(positioned, point.yPt);
|
|
57
|
+
writer.writeAscii(`${require_serialize.formatNumber(x)} ${require_serialize.formatNumber(y)} ${index === 0 ? "m" : "l"}\n`);
|
|
58
|
+
});
|
|
59
|
+
writer.writeAscii("S\n");
|
|
60
|
+
}
|
|
61
|
+
function writeFormulaContentStream(formulas, ctx) {
|
|
62
|
+
const writer = new require_bytes_writer.ByteWriter();
|
|
63
|
+
for (const positioned of formulas) for (const item of positioned.box.items) if (item.kind === "glyphs") writeGlyphRun(writer, positioned, item, ctx);
|
|
64
|
+
else if (item.kind === "rule") writeRule(writer, positioned, item);
|
|
65
|
+
else writeStroke(writer, positioned, item);
|
|
66
|
+
return writer.toBytes();
|
|
67
|
+
}
|
|
68
|
+
function collectUsedGlyphs(formulas, font) {
|
|
69
|
+
const used = /* @__PURE__ */ new Map();
|
|
70
|
+
for (const positioned of formulas) for (const item of positioned.box.items) {
|
|
71
|
+
if (item.kind !== "glyphs") continue;
|
|
72
|
+
for (const ch of item.text) {
|
|
73
|
+
const codePoint = ch.codePointAt(0);
|
|
74
|
+
if (codePoint === void 0) continue;
|
|
75
|
+
const glyphId = font.glyphId(codePoint);
|
|
76
|
+
if (glyphId !== void 0 && !used.has(glyphId)) used.set(glyphId, codePoint);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return used;
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
exports.collectUsedGlyphs = collectUsedGlyphs;
|
|
83
|
+
exports.writeFormulaContentStream = writeFormulaContentStream;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PositionedFormula } from "./formula.cjs";
|
|
2
|
+
import { MathFont } from "./math-font.cjs";
|
|
3
|
+
//#region src/math-content-write.d.ts
|
|
4
|
+
interface MathContentWriteContext {
|
|
5
|
+
readonly font: MathFont;
|
|
6
|
+
readonly resourceName: string;
|
|
7
|
+
}
|
|
8
|
+
declare function writeFormulaContentStream(formulas: readonly PositionedFormula[], ctx: MathContentWriteContext): Uint8Array<ArrayBuffer>;
|
|
9
|
+
declare function collectUsedGlyphs(formulas: readonly PositionedFormula[], font: MathFont): ReadonlyMap<number, number>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { MathContentWriteContext, collectUsedGlyphs, writeFormulaContentStream };
|