pdf-parser.js 5.2.27 → 5.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{afm-widths-BYiX2L9D.cjs → afm-widths-BHD2HZIL.cjs} +553 -642
- package/dist/{afm-widths-blUDDjlI.js → afm-widths-B_IGbGky.js} +553 -642
- package/dist/afm-widths.cjs +1 -1
- package/dist/afm-widths.js +1 -1
- package/dist/annotations.cjs +5 -3
- package/dist/annotations.js +5 -3
- package/dist/builtin-encoding.cjs +17 -6
- package/dist/builtin-encoding.js +17 -6
- package/dist/bytes/crc32.cjs +5 -3
- package/dist/bytes/crc32.js +5 -3
- package/dist/bytes/flate.cjs +0 -1
- package/dist/bytes/flate.js +0 -1
- package/dist/cff-bounds.cjs +42 -24
- package/dist/cff-bounds.js +42 -24
- package/dist/cff.cjs +13 -6
- package/dist/cff.js +13 -6
- package/dist/cmap-table.cjs +54 -26
- package/dist/cmap-table.js +54 -26
- package/dist/cmap.cjs +5 -3
- package/dist/cmap.js +5 -3
- package/dist/content-write.cjs +3 -2
- package/dist/content-write.js +3 -2
- package/dist/crypto/aes.cjs +76 -55
- package/dist/crypto/aes.js +76 -55
- package/dist/crypto/md5.cjs +345 -149
- package/dist/crypto/md5.js +345 -149
- package/dist/crypto/rc4.cjs +5 -4
- package/dist/crypto/rc4.js +5 -4
- package/dist/crypto/sha2.cjs +92 -43
- package/dist/crypto/sha2.js +92 -43
- package/dist/embedded-font.cjs +4 -2
- package/dist/embedded-font.js +4 -2
- package/dist/encoding.cjs +1 -1
- package/dist/encoding.js +1 -1
- package/dist/encrypt-write.cjs +25 -21
- package/dist/encrypt-write.js +25 -21
- package/dist/encrypt.cjs +43 -64
- package/dist/encrypt.js +43 -64
- package/dist/filters.cjs +40 -20
- package/dist/filters.js +40 -20
- package/dist/font-face.cjs +2 -1
- package/dist/font-face.js +2 -1
- package/dist/font-read.cjs +12 -6
- package/dist/font-read.js +12 -6
- package/dist/font-tables.cjs +55 -28
- package/dist/font-tables.js +55 -28
- package/dist/gdef-table.cjs +6 -3
- package/dist/gdef-table.js +6 -3
- package/dist/glyf-contours.cjs +3 -1
- package/dist/glyf-contours.js +3 -1
- package/dist/glyf.cjs +22 -11
- package/dist/glyf.js +22 -11
- package/dist/gpos-table.cjs +37 -19
- package/dist/gpos-table.js +37 -19
- package/dist/gsub-table.cjs +28 -17
- package/dist/gsub-table.js +28 -17
- package/dist/hmtx-table.cjs +5 -3
- package/dist/hmtx-table.js +5 -3
- package/dist/image/ccitt-encode.cjs +8 -5
- package/dist/image/ccitt-encode.js +8 -5
- package/dist/image/ccitt.cjs +801 -209
- package/dist/image/ccitt.js +801 -209
- package/dist/image/jbig2-arith.cjs +340 -306
- package/dist/image/jbig2-arith.js +340 -306
- package/dist/image/jbig2-bitmap.cjs +8 -5
- package/dist/image/jbig2-bitmap.js +8 -5
- package/dist/image/jbig2-generic.cjs +240 -69
- package/dist/image/jbig2-generic.js +240 -69
- package/dist/image/jbig2-text.cjs +4 -2
- package/dist/image/jbig2-text.js +4 -2
- package/dist/image/jbig2.cjs +69 -31
- package/dist/image/jbig2.js +69 -31
- package/dist/image/jp2-boxes.cjs +52 -27
- package/dist/image/jp2-boxes.js +52 -27
- package/dist/image/jpeg-info.cjs +29 -24
- package/dist/image/jpeg-info.js +29 -24
- package/dist/image/jpeg2000-codestream.cjs +44 -24
- package/dist/image/jpeg2000-codestream.js +44 -24
- package/dist/image/jpeg2000-dwt.cjs +2 -1
- package/dist/image/jpeg2000-dwt.js +2 -1
- package/dist/image/jpeg2000-t1.cjs +21 -11
- package/dist/image/jpeg2000-t1.js +21 -11
- package/dist/image/jpeg2000-t2.cjs +12 -5
- package/dist/image/jpeg2000-t2.js +12 -5
- package/dist/image/jpeg2000-tagtree.cjs +8 -4
- package/dist/image/jpeg2000-tagtree.js +8 -4
- package/dist/image/jpeg2000.cjs +11 -6
- package/dist/image/jpeg2000.js +11 -6
- package/dist/image/png-decode.cjs +62 -39
- package/dist/image/png-decode.d.cts +3 -2
- package/dist/image/png-decode.d.ts +3 -2
- package/dist/image/png-decode.js +62 -39
- package/dist/image/png-filter.cjs +23 -15
- package/dist/image/png-filter.js +23 -15
- package/dist/images-read.cjs +41 -36
- package/dist/images-read.js +41 -36
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/interpret.cjs +39 -24
- package/dist/interpret.js +39 -24
- package/dist/lexer.cjs +86 -51
- package/dist/lexer.js +86 -51
- package/dist/math-content-write.cjs +9 -5
- package/dist/math-content-write.js +9 -5
- package/dist/math-font-write.cjs +2 -1
- package/dist/math-font-write.js +2 -1
- package/dist/math-font.cjs +16 -7
- package/dist/math-font.js +16 -7
- package/dist/math-table.cjs +25 -13
- package/dist/math-table.js +25 -13
- package/dist/matrix.cjs +3 -2
- package/dist/matrix.js +3 -2
- package/dist/measure.cjs +1 -1
- package/dist/measure.js +1 -1
- package/dist/navigation.cjs +10 -5
- package/dist/navigation.js +10 -5
- package/dist/ot-layout-common.cjs +4 -2
- package/dist/ot-layout-common.js +4 -2
- package/dist/parse.cjs +7 -5
- package/dist/parse.js +7 -5
- package/dist/pdf-text.cjs +5 -2
- package/dist/pdf-text.js +5 -2
- package/dist/predictors.cjs +14 -9
- package/dist/predictors.js +14 -9
- package/dist/raster.cjs +30 -19
- package/dist/raster.js +30 -19
- package/dist/read.cjs +17 -8
- package/dist/read.js +17 -8
- package/dist/serialize.cjs +6 -2
- package/dist/serialize.js +6 -2
- package/dist/sfnt-subset.cjs +25 -13
- package/dist/sfnt-subset.js +25 -13
- package/dist/sfnt.cjs +20 -10
- package/dist/sfnt.js +20 -10
- package/dist/text-group.cjs +0 -1
- package/dist/text-group.js +0 -1
- package/dist/tounicode.cjs +4 -2
- package/dist/tounicode.js +4 -2
- package/dist/winansi.cjs +1 -1
- package/dist/winansi.js +1 -1
- package/dist/write.cjs +20 -12
- package/dist/write.js +20 -12
- package/dist/xref.cjs +5 -2
- package/dist/xref.js +5 -2
- package/package.json +2 -2
package/dist/lexer.cjs
CHANGED
|
@@ -1,44 +1,79 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_bytes_reader = require("./bytes/reader.cjs");
|
|
3
3
|
//#region src/lexer.ts
|
|
4
|
+
const LEFT_PAREN = 40;
|
|
5
|
+
const RIGHT_PAREN = 41;
|
|
6
|
+
const LESS_THAN = 60;
|
|
7
|
+
const GREATER_THAN = 62;
|
|
8
|
+
const LEFT_BRACKET = 91;
|
|
9
|
+
const RIGHT_BRACKET = 93;
|
|
10
|
+
const LEFT_BRACE = 123;
|
|
11
|
+
const RIGHT_BRACE = 125;
|
|
12
|
+
const SOLIDUS = 47;
|
|
13
|
+
const PERCENT_SIGN = 37;
|
|
14
|
+
const REVERSE_SOLIDUS = 92;
|
|
15
|
+
const NUMBER_SIGN = 35;
|
|
16
|
+
const PLUS_SIGN = 43;
|
|
17
|
+
const MINUS_SIGN = 45;
|
|
18
|
+
const FULL_STOP = 46;
|
|
19
|
+
const LINE_FEED = 10;
|
|
20
|
+
const CARRIAGE_RETURN = 13;
|
|
21
|
+
const HORIZONTAL_TAB = 9;
|
|
22
|
+
const BACKSPACE = 8;
|
|
23
|
+
const FORM_FEED = 12;
|
|
24
|
+
const DIGIT_ZERO = 48;
|
|
25
|
+
const DIGIT_SEVEN = 55;
|
|
26
|
+
const DIGIT_NINE = 57;
|
|
27
|
+
const UPPER_A = 65;
|
|
28
|
+
const UPPER_F = 70;
|
|
29
|
+
const LOWER_A = 97;
|
|
30
|
+
const LOWER_B = 98;
|
|
31
|
+
const LOWER_F = 102;
|
|
32
|
+
const LOWER_N = 110;
|
|
33
|
+
const LOWER_R = 114;
|
|
34
|
+
const LOWER_T = 116;
|
|
35
|
+
const HEX_DIGIT_ALPHA_OFFSET = 10;
|
|
36
|
+
const HEX_RADIX = 16;
|
|
37
|
+
const OCTAL_RADIX = 8;
|
|
38
|
+
const BYTE_MASK = 255;
|
|
4
39
|
const DELIMITER_BYTES = /* @__PURE__ */ new Set([
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
40
|
+
LEFT_PAREN,
|
|
41
|
+
RIGHT_PAREN,
|
|
42
|
+
LESS_THAN,
|
|
43
|
+
GREATER_THAN,
|
|
44
|
+
LEFT_BRACKET,
|
|
45
|
+
RIGHT_BRACKET,
|
|
46
|
+
LEFT_BRACE,
|
|
47
|
+
RIGHT_BRACE,
|
|
48
|
+
SOLIDUS,
|
|
49
|
+
PERCENT_SIGN
|
|
15
50
|
]);
|
|
16
51
|
function isRegularByte(byte) {
|
|
17
52
|
return !require_bytes_reader.isAsciiWhitespace(byte) && !DELIMITER_BYTES.has(byte);
|
|
18
53
|
}
|
|
19
54
|
function isDigit(byte) {
|
|
20
|
-
return byte !== void 0 && byte >=
|
|
55
|
+
return byte !== void 0 && byte >= DIGIT_ZERO && byte <= DIGIT_NINE;
|
|
21
56
|
}
|
|
22
57
|
function isHexDigit(byte) {
|
|
23
|
-
return byte !== void 0 && (byte >=
|
|
58
|
+
return byte !== void 0 && (byte >= DIGIT_ZERO && byte <= DIGIT_NINE || byte >= UPPER_A && byte <= UPPER_F || byte >= LOWER_A && byte <= LOWER_F);
|
|
24
59
|
}
|
|
25
60
|
function hexDigitValue(byte) {
|
|
26
|
-
if (byte >=
|
|
27
|
-
if (byte >=
|
|
28
|
-
return byte -
|
|
61
|
+
if (byte >= DIGIT_ZERO && byte <= DIGIT_NINE) return byte - DIGIT_ZERO;
|
|
62
|
+
if (byte >= UPPER_A && byte <= UPPER_F) return byte - UPPER_A + HEX_DIGIT_ALPHA_OFFSET;
|
|
63
|
+
return byte - LOWER_A + HEX_DIGIT_ALPHA_OFFSET;
|
|
29
64
|
}
|
|
30
65
|
function skipWhitespaceAndComments(reader) {
|
|
31
66
|
for (;;) {
|
|
32
67
|
reader.skipWhitespace();
|
|
33
|
-
if (reader.peek() !==
|
|
34
|
-
while (!reader.atEnd() && reader.peek() !==
|
|
68
|
+
if (reader.peek() !== PERCENT_SIGN) return;
|
|
69
|
+
while (!reader.atEnd() && reader.peek() !== LINE_FEED && reader.peek() !== CARRIAGE_RETURN) reader.next();
|
|
35
70
|
}
|
|
36
71
|
}
|
|
37
72
|
function readNumberToken(reader) {
|
|
38
73
|
const start = reader.offset;
|
|
39
|
-
if (reader.peek() ===
|
|
74
|
+
if (reader.peek() === PLUS_SIGN || reader.peek() === MINUS_SIGN) reader.next();
|
|
40
75
|
while (isDigit(reader.peek())) reader.next();
|
|
41
|
-
if (reader.peek() ===
|
|
76
|
+
if (reader.peek() === FULL_STOP) {
|
|
42
77
|
reader.next();
|
|
43
78
|
while (isDigit(reader.peek())) reader.next();
|
|
44
79
|
}
|
|
@@ -54,11 +89,11 @@ function readNameToken(reader) {
|
|
|
54
89
|
for (;;) {
|
|
55
90
|
const byte = reader.peek();
|
|
56
91
|
if (byte === void 0 || !isRegularByte(byte)) break;
|
|
57
|
-
if (byte ===
|
|
92
|
+
if (byte === NUMBER_SIGN && isHexDigit(reader.peek(1)) && isHexDigit(reader.peek(2))) {
|
|
58
93
|
reader.next();
|
|
59
94
|
const hi = hexDigitValue(reader.next());
|
|
60
95
|
const lo = hexDigitValue(reader.next());
|
|
61
|
-
bytes.push(hi *
|
|
96
|
+
bytes.push(hi * HEX_RADIX + lo);
|
|
62
97
|
} else bytes.push(reader.next());
|
|
63
98
|
}
|
|
64
99
|
return {
|
|
@@ -73,38 +108,38 @@ function readLiteralStringToken(reader) {
|
|
|
73
108
|
for (;;) {
|
|
74
109
|
const byte = reader.next();
|
|
75
110
|
if (byte === void 0) break;
|
|
76
|
-
if (byte ===
|
|
111
|
+
if (byte === REVERSE_SOLIDUS) {
|
|
77
112
|
const esc = reader.next();
|
|
78
113
|
if (esc === void 0) break;
|
|
79
|
-
if (esc ===
|
|
80
|
-
else if (esc ===
|
|
81
|
-
else if (esc ===
|
|
82
|
-
else if (esc ===
|
|
83
|
-
else if (esc ===
|
|
84
|
-
else if (esc ===
|
|
85
|
-
else if (esc ===
|
|
86
|
-
if (reader.peek() ===
|
|
87
|
-
} else if (esc ===
|
|
88
|
-
let value = esc -
|
|
89
|
-
for (let i = 0; i < 2 && reader.peek() !== void 0 && reader.peek() >=
|
|
90
|
-
bytes.push(value &
|
|
114
|
+
if (esc === LOWER_N) bytes.push(LINE_FEED);
|
|
115
|
+
else if (esc === LOWER_R) bytes.push(CARRIAGE_RETURN);
|
|
116
|
+
else if (esc === LOWER_T) bytes.push(HORIZONTAL_TAB);
|
|
117
|
+
else if (esc === LOWER_B) bytes.push(BACKSPACE);
|
|
118
|
+
else if (esc === LOWER_F) bytes.push(FORM_FEED);
|
|
119
|
+
else if (esc === LEFT_PAREN || esc === RIGHT_PAREN || esc === REVERSE_SOLIDUS) bytes.push(esc);
|
|
120
|
+
else if (esc === CARRIAGE_RETURN) {
|
|
121
|
+
if (reader.peek() === LINE_FEED) reader.next();
|
|
122
|
+
} else if (esc === LINE_FEED) {} else if (esc >= DIGIT_ZERO && esc <= DIGIT_SEVEN) {
|
|
123
|
+
let value = esc - DIGIT_ZERO;
|
|
124
|
+
for (let i = 0; i < 2 && reader.peek() !== void 0 && reader.peek() >= DIGIT_ZERO && reader.peek() <= DIGIT_SEVEN; i++) value = value * OCTAL_RADIX + (reader.next() - DIGIT_ZERO);
|
|
125
|
+
bytes.push(value & BYTE_MASK);
|
|
91
126
|
} else bytes.push(esc);
|
|
92
127
|
continue;
|
|
93
128
|
}
|
|
94
|
-
if (byte ===
|
|
129
|
+
if (byte === LEFT_PAREN) {
|
|
95
130
|
depth++;
|
|
96
131
|
bytes.push(byte);
|
|
97
132
|
continue;
|
|
98
133
|
}
|
|
99
|
-
if (byte ===
|
|
134
|
+
if (byte === RIGHT_PAREN) {
|
|
100
135
|
depth--;
|
|
101
136
|
if (depth === 0) break;
|
|
102
137
|
bytes.push(byte);
|
|
103
138
|
continue;
|
|
104
139
|
}
|
|
105
|
-
if (byte ===
|
|
106
|
-
if (reader.peek() ===
|
|
107
|
-
bytes.push(
|
|
140
|
+
if (byte === CARRIAGE_RETURN) {
|
|
141
|
+
if (reader.peek() === LINE_FEED) reader.next();
|
|
142
|
+
bytes.push(LINE_FEED);
|
|
108
143
|
continue;
|
|
109
144
|
}
|
|
110
145
|
bytes.push(byte);
|
|
@@ -119,12 +154,12 @@ function readHexStringToken(reader) {
|
|
|
119
154
|
const digits = [];
|
|
120
155
|
for (;;) {
|
|
121
156
|
const byte = reader.next();
|
|
122
|
-
if (byte === void 0 || byte ===
|
|
157
|
+
if (byte === void 0 || byte === GREATER_THAN) break;
|
|
123
158
|
if (isHexDigit(byte)) digits.push(hexDigitValue(byte));
|
|
124
159
|
}
|
|
125
160
|
if (digits.length % 2 === 1) digits.push(0);
|
|
126
161
|
const bytes = new Uint8Array(digits.length / 2);
|
|
127
|
-
for (let i = 0; i < bytes.length; i++) bytes[i] = digits[i * 2] *
|
|
162
|
+
for (let i = 0; i < bytes.length; i++) bytes[i] = digits[i * 2] * HEX_RADIX + digits[i * 2 + 1];
|
|
128
163
|
return {
|
|
129
164
|
kind: "hexString",
|
|
130
165
|
value: bytes
|
|
@@ -142,18 +177,18 @@ function nextToken(reader) {
|
|
|
142
177
|
skipWhitespaceAndComments(reader);
|
|
143
178
|
const byte = reader.peek();
|
|
144
179
|
if (byte === void 0) return;
|
|
145
|
-
if (byte ===
|
|
146
|
-
if (byte ===
|
|
147
|
-
if (byte ===
|
|
148
|
-
if (reader.peek(1) ===
|
|
180
|
+
if (byte === SOLIDUS) return readNameToken(reader);
|
|
181
|
+
if (byte === LEFT_PAREN) return readLiteralStringToken(reader);
|
|
182
|
+
if (byte === LESS_THAN) {
|
|
183
|
+
if (reader.peek(1) === LESS_THAN) {
|
|
149
184
|
reader.next();
|
|
150
185
|
reader.next();
|
|
151
186
|
return { kind: "dictStart" };
|
|
152
187
|
}
|
|
153
188
|
return readHexStringToken(reader);
|
|
154
189
|
}
|
|
155
|
-
if (byte ===
|
|
156
|
-
if (reader.peek(1) ===
|
|
190
|
+
if (byte === GREATER_THAN) {
|
|
191
|
+
if (reader.peek(1) === GREATER_THAN) {
|
|
157
192
|
reader.next();
|
|
158
193
|
reader.next();
|
|
159
194
|
return { kind: "dictEnd" };
|
|
@@ -161,19 +196,19 @@ function nextToken(reader) {
|
|
|
161
196
|
reader.next();
|
|
162
197
|
return nextToken(reader);
|
|
163
198
|
}
|
|
164
|
-
if (byte ===
|
|
199
|
+
if (byte === LEFT_BRACKET) {
|
|
165
200
|
reader.next();
|
|
166
201
|
return { kind: "arrayStart" };
|
|
167
202
|
}
|
|
168
|
-
if (byte ===
|
|
203
|
+
if (byte === RIGHT_BRACKET) {
|
|
169
204
|
reader.next();
|
|
170
205
|
return { kind: "arrayEnd" };
|
|
171
206
|
}
|
|
172
|
-
if (byte ===
|
|
207
|
+
if (byte === LEFT_BRACE || byte === RIGHT_BRACE) {
|
|
173
208
|
reader.next();
|
|
174
209
|
return nextToken(reader);
|
|
175
210
|
}
|
|
176
|
-
if (byte ===
|
|
211
|
+
if (byte === PLUS_SIGN || byte === MINUS_SIGN || byte === FULL_STOP || isDigit(byte)) return readNumberToken(reader);
|
|
177
212
|
return readKeywordToken(reader);
|
|
178
213
|
}
|
|
179
214
|
//#endregion
|
package/dist/lexer.js
CHANGED
|
@@ -1,43 +1,78 @@
|
|
|
1
1
|
import { isAsciiWhitespace } from "./bytes/reader.js";
|
|
2
2
|
//#region src/lexer.ts
|
|
3
|
+
const LEFT_PAREN = 40;
|
|
4
|
+
const RIGHT_PAREN = 41;
|
|
5
|
+
const LESS_THAN = 60;
|
|
6
|
+
const GREATER_THAN = 62;
|
|
7
|
+
const LEFT_BRACKET = 91;
|
|
8
|
+
const RIGHT_BRACKET = 93;
|
|
9
|
+
const LEFT_BRACE = 123;
|
|
10
|
+
const RIGHT_BRACE = 125;
|
|
11
|
+
const SOLIDUS = 47;
|
|
12
|
+
const PERCENT_SIGN = 37;
|
|
13
|
+
const REVERSE_SOLIDUS = 92;
|
|
14
|
+
const NUMBER_SIGN = 35;
|
|
15
|
+
const PLUS_SIGN = 43;
|
|
16
|
+
const MINUS_SIGN = 45;
|
|
17
|
+
const FULL_STOP = 46;
|
|
18
|
+
const LINE_FEED = 10;
|
|
19
|
+
const CARRIAGE_RETURN = 13;
|
|
20
|
+
const HORIZONTAL_TAB = 9;
|
|
21
|
+
const BACKSPACE = 8;
|
|
22
|
+
const FORM_FEED = 12;
|
|
23
|
+
const DIGIT_ZERO = 48;
|
|
24
|
+
const DIGIT_SEVEN = 55;
|
|
25
|
+
const DIGIT_NINE = 57;
|
|
26
|
+
const UPPER_A = 65;
|
|
27
|
+
const UPPER_F = 70;
|
|
28
|
+
const LOWER_A = 97;
|
|
29
|
+
const LOWER_B = 98;
|
|
30
|
+
const LOWER_F = 102;
|
|
31
|
+
const LOWER_N = 110;
|
|
32
|
+
const LOWER_R = 114;
|
|
33
|
+
const LOWER_T = 116;
|
|
34
|
+
const HEX_DIGIT_ALPHA_OFFSET = 10;
|
|
35
|
+
const HEX_RADIX = 16;
|
|
36
|
+
const OCTAL_RADIX = 8;
|
|
37
|
+
const BYTE_MASK = 255;
|
|
3
38
|
const DELIMITER_BYTES = /* @__PURE__ */ new Set([
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
39
|
+
LEFT_PAREN,
|
|
40
|
+
RIGHT_PAREN,
|
|
41
|
+
LESS_THAN,
|
|
42
|
+
GREATER_THAN,
|
|
43
|
+
LEFT_BRACKET,
|
|
44
|
+
RIGHT_BRACKET,
|
|
45
|
+
LEFT_BRACE,
|
|
46
|
+
RIGHT_BRACE,
|
|
47
|
+
SOLIDUS,
|
|
48
|
+
PERCENT_SIGN
|
|
14
49
|
]);
|
|
15
50
|
function isRegularByte(byte) {
|
|
16
51
|
return !isAsciiWhitespace(byte) && !DELIMITER_BYTES.has(byte);
|
|
17
52
|
}
|
|
18
53
|
function isDigit(byte) {
|
|
19
|
-
return byte !== void 0 && byte >=
|
|
54
|
+
return byte !== void 0 && byte >= DIGIT_ZERO && byte <= DIGIT_NINE;
|
|
20
55
|
}
|
|
21
56
|
function isHexDigit(byte) {
|
|
22
|
-
return byte !== void 0 && (byte >=
|
|
57
|
+
return byte !== void 0 && (byte >= DIGIT_ZERO && byte <= DIGIT_NINE || byte >= UPPER_A && byte <= UPPER_F || byte >= LOWER_A && byte <= LOWER_F);
|
|
23
58
|
}
|
|
24
59
|
function hexDigitValue(byte) {
|
|
25
|
-
if (byte >=
|
|
26
|
-
if (byte >=
|
|
27
|
-
return byte -
|
|
60
|
+
if (byte >= DIGIT_ZERO && byte <= DIGIT_NINE) return byte - DIGIT_ZERO;
|
|
61
|
+
if (byte >= UPPER_A && byte <= UPPER_F) return byte - UPPER_A + HEX_DIGIT_ALPHA_OFFSET;
|
|
62
|
+
return byte - LOWER_A + HEX_DIGIT_ALPHA_OFFSET;
|
|
28
63
|
}
|
|
29
64
|
function skipWhitespaceAndComments(reader) {
|
|
30
65
|
for (;;) {
|
|
31
66
|
reader.skipWhitespace();
|
|
32
|
-
if (reader.peek() !==
|
|
33
|
-
while (!reader.atEnd() && reader.peek() !==
|
|
67
|
+
if (reader.peek() !== PERCENT_SIGN) return;
|
|
68
|
+
while (!reader.atEnd() && reader.peek() !== LINE_FEED && reader.peek() !== CARRIAGE_RETURN) reader.next();
|
|
34
69
|
}
|
|
35
70
|
}
|
|
36
71
|
function readNumberToken(reader) {
|
|
37
72
|
const start = reader.offset;
|
|
38
|
-
if (reader.peek() ===
|
|
73
|
+
if (reader.peek() === PLUS_SIGN || reader.peek() === MINUS_SIGN) reader.next();
|
|
39
74
|
while (isDigit(reader.peek())) reader.next();
|
|
40
|
-
if (reader.peek() ===
|
|
75
|
+
if (reader.peek() === FULL_STOP) {
|
|
41
76
|
reader.next();
|
|
42
77
|
while (isDigit(reader.peek())) reader.next();
|
|
43
78
|
}
|
|
@@ -53,11 +88,11 @@ function readNameToken(reader) {
|
|
|
53
88
|
for (;;) {
|
|
54
89
|
const byte = reader.peek();
|
|
55
90
|
if (byte === void 0 || !isRegularByte(byte)) break;
|
|
56
|
-
if (byte ===
|
|
91
|
+
if (byte === NUMBER_SIGN && isHexDigit(reader.peek(1)) && isHexDigit(reader.peek(2))) {
|
|
57
92
|
reader.next();
|
|
58
93
|
const hi = hexDigitValue(reader.next());
|
|
59
94
|
const lo = hexDigitValue(reader.next());
|
|
60
|
-
bytes.push(hi *
|
|
95
|
+
bytes.push(hi * HEX_RADIX + lo);
|
|
61
96
|
} else bytes.push(reader.next());
|
|
62
97
|
}
|
|
63
98
|
return {
|
|
@@ -72,38 +107,38 @@ function readLiteralStringToken(reader) {
|
|
|
72
107
|
for (;;) {
|
|
73
108
|
const byte = reader.next();
|
|
74
109
|
if (byte === void 0) break;
|
|
75
|
-
if (byte ===
|
|
110
|
+
if (byte === REVERSE_SOLIDUS) {
|
|
76
111
|
const esc = reader.next();
|
|
77
112
|
if (esc === void 0) break;
|
|
78
|
-
if (esc ===
|
|
79
|
-
else if (esc ===
|
|
80
|
-
else if (esc ===
|
|
81
|
-
else if (esc ===
|
|
82
|
-
else if (esc ===
|
|
83
|
-
else if (esc ===
|
|
84
|
-
else if (esc ===
|
|
85
|
-
if (reader.peek() ===
|
|
86
|
-
} else if (esc ===
|
|
87
|
-
let value = esc -
|
|
88
|
-
for (let i = 0; i < 2 && reader.peek() !== void 0 && reader.peek() >=
|
|
89
|
-
bytes.push(value &
|
|
113
|
+
if (esc === LOWER_N) bytes.push(LINE_FEED);
|
|
114
|
+
else if (esc === LOWER_R) bytes.push(CARRIAGE_RETURN);
|
|
115
|
+
else if (esc === LOWER_T) bytes.push(HORIZONTAL_TAB);
|
|
116
|
+
else if (esc === LOWER_B) bytes.push(BACKSPACE);
|
|
117
|
+
else if (esc === LOWER_F) bytes.push(FORM_FEED);
|
|
118
|
+
else if (esc === LEFT_PAREN || esc === RIGHT_PAREN || esc === REVERSE_SOLIDUS) bytes.push(esc);
|
|
119
|
+
else if (esc === CARRIAGE_RETURN) {
|
|
120
|
+
if (reader.peek() === LINE_FEED) reader.next();
|
|
121
|
+
} else if (esc === LINE_FEED) {} else if (esc >= DIGIT_ZERO && esc <= DIGIT_SEVEN) {
|
|
122
|
+
let value = esc - DIGIT_ZERO;
|
|
123
|
+
for (let i = 0; i < 2 && reader.peek() !== void 0 && reader.peek() >= DIGIT_ZERO && reader.peek() <= DIGIT_SEVEN; i++) value = value * OCTAL_RADIX + (reader.next() - DIGIT_ZERO);
|
|
124
|
+
bytes.push(value & BYTE_MASK);
|
|
90
125
|
} else bytes.push(esc);
|
|
91
126
|
continue;
|
|
92
127
|
}
|
|
93
|
-
if (byte ===
|
|
128
|
+
if (byte === LEFT_PAREN) {
|
|
94
129
|
depth++;
|
|
95
130
|
bytes.push(byte);
|
|
96
131
|
continue;
|
|
97
132
|
}
|
|
98
|
-
if (byte ===
|
|
133
|
+
if (byte === RIGHT_PAREN) {
|
|
99
134
|
depth--;
|
|
100
135
|
if (depth === 0) break;
|
|
101
136
|
bytes.push(byte);
|
|
102
137
|
continue;
|
|
103
138
|
}
|
|
104
|
-
if (byte ===
|
|
105
|
-
if (reader.peek() ===
|
|
106
|
-
bytes.push(
|
|
139
|
+
if (byte === CARRIAGE_RETURN) {
|
|
140
|
+
if (reader.peek() === LINE_FEED) reader.next();
|
|
141
|
+
bytes.push(LINE_FEED);
|
|
107
142
|
continue;
|
|
108
143
|
}
|
|
109
144
|
bytes.push(byte);
|
|
@@ -118,12 +153,12 @@ function readHexStringToken(reader) {
|
|
|
118
153
|
const digits = [];
|
|
119
154
|
for (;;) {
|
|
120
155
|
const byte = reader.next();
|
|
121
|
-
if (byte === void 0 || byte ===
|
|
156
|
+
if (byte === void 0 || byte === GREATER_THAN) break;
|
|
122
157
|
if (isHexDigit(byte)) digits.push(hexDigitValue(byte));
|
|
123
158
|
}
|
|
124
159
|
if (digits.length % 2 === 1) digits.push(0);
|
|
125
160
|
const bytes = new Uint8Array(digits.length / 2);
|
|
126
|
-
for (let i = 0; i < bytes.length; i++) bytes[i] = digits[i * 2] *
|
|
161
|
+
for (let i = 0; i < bytes.length; i++) bytes[i] = digits[i * 2] * HEX_RADIX + digits[i * 2 + 1];
|
|
127
162
|
return {
|
|
128
163
|
kind: "hexString",
|
|
129
164
|
value: bytes
|
|
@@ -141,18 +176,18 @@ function nextToken(reader) {
|
|
|
141
176
|
skipWhitespaceAndComments(reader);
|
|
142
177
|
const byte = reader.peek();
|
|
143
178
|
if (byte === void 0) return;
|
|
144
|
-
if (byte ===
|
|
145
|
-
if (byte ===
|
|
146
|
-
if (byte ===
|
|
147
|
-
if (reader.peek(1) ===
|
|
179
|
+
if (byte === SOLIDUS) return readNameToken(reader);
|
|
180
|
+
if (byte === LEFT_PAREN) return readLiteralStringToken(reader);
|
|
181
|
+
if (byte === LESS_THAN) {
|
|
182
|
+
if (reader.peek(1) === LESS_THAN) {
|
|
148
183
|
reader.next();
|
|
149
184
|
reader.next();
|
|
150
185
|
return { kind: "dictStart" };
|
|
151
186
|
}
|
|
152
187
|
return readHexStringToken(reader);
|
|
153
188
|
}
|
|
154
|
-
if (byte ===
|
|
155
|
-
if (reader.peek(1) ===
|
|
189
|
+
if (byte === GREATER_THAN) {
|
|
190
|
+
if (reader.peek(1) === GREATER_THAN) {
|
|
156
191
|
reader.next();
|
|
157
192
|
reader.next();
|
|
158
193
|
return { kind: "dictEnd" };
|
|
@@ -160,19 +195,19 @@ function nextToken(reader) {
|
|
|
160
195
|
reader.next();
|
|
161
196
|
return nextToken(reader);
|
|
162
197
|
}
|
|
163
|
-
if (byte ===
|
|
198
|
+
if (byte === LEFT_BRACKET) {
|
|
164
199
|
reader.next();
|
|
165
200
|
return { kind: "arrayStart" };
|
|
166
201
|
}
|
|
167
|
-
if (byte ===
|
|
202
|
+
if (byte === RIGHT_BRACKET) {
|
|
168
203
|
reader.next();
|
|
169
204
|
return { kind: "arrayEnd" };
|
|
170
205
|
}
|
|
171
|
-
if (byte ===
|
|
206
|
+
if (byte === LEFT_BRACE || byte === RIGHT_BRACE) {
|
|
172
207
|
reader.next();
|
|
173
208
|
return nextToken(reader);
|
|
174
209
|
}
|
|
175
|
-
if (byte ===
|
|
210
|
+
if (byte === PLUS_SIGN || byte === MINUS_SIGN || byte === FULL_STOP || isDigit(byte)) return readNumberToken(reader);
|
|
176
211
|
return readKeywordToken(reader);
|
|
177
212
|
}
|
|
178
213
|
//#endregion
|
|
@@ -9,6 +9,8 @@ function toPdfX(positioned, itemXPt) {
|
|
|
9
9
|
function toPdfY(positioned, itemYPt) {
|
|
10
10
|
return positioned.yPt + positioned.box.heightPt - itemYPt;
|
|
11
11
|
}
|
|
12
|
+
const BITS_PER_BYTE = 8;
|
|
13
|
+
const BYTE_MASK = 255;
|
|
12
14
|
function writeRgbOperator(writer, color, operator) {
|
|
13
15
|
writer.writeAscii(`${require_serialize.formatNumber(color.r)} ${require_serialize.formatNumber(color.g)} ${require_serialize.formatNumber(color.b)} ${operator}\n`);
|
|
14
16
|
}
|
|
@@ -22,8 +24,8 @@ function encodeGlyphRunToCids(font, text) {
|
|
|
22
24
|
}
|
|
23
25
|
const bytes = new Uint8Array(gids.length * 2);
|
|
24
26
|
gids.forEach((gid, index) => {
|
|
25
|
-
bytes[index * 2] = gid >>
|
|
26
|
-
bytes[index * 2 + 1] = gid &
|
|
27
|
+
bytes[index * 2] = gid >> BITS_PER_BYTE & BYTE_MASK;
|
|
28
|
+
bytes[index * 2 + 1] = gid & BYTE_MASK;
|
|
27
29
|
});
|
|
28
30
|
return bytes;
|
|
29
31
|
}
|
|
@@ -41,13 +43,15 @@ function writeGlyphRun(writer, positioned, item, ctx) {
|
|
|
41
43
|
writer.writeAscii("ET\n");
|
|
42
44
|
}
|
|
43
45
|
function cidBytes(glyphId) {
|
|
44
|
-
return new Uint8Array([glyphId >>
|
|
46
|
+
return new Uint8Array([glyphId >> BITS_PER_BYTE & BYTE_MASK, glyphId & BYTE_MASK]);
|
|
45
47
|
}
|
|
48
|
+
const UTF16_BOM_HIGH_BYTE = 254;
|
|
49
|
+
const UTF16_BOM_LOW_BYTE = 255;
|
|
46
50
|
function utf16BeWithBom(text) {
|
|
47
|
-
const bytes = [
|
|
51
|
+
const bytes = [UTF16_BOM_HIGH_BYTE, UTF16_BOM_LOW_BYTE];
|
|
48
52
|
for (let i = 0; i < text.length; i++) {
|
|
49
53
|
const unit = text.charCodeAt(i);
|
|
50
|
-
bytes.push(unit >>
|
|
54
|
+
bytes.push(unit >> BITS_PER_BYTE & BYTE_MASK, unit & BYTE_MASK);
|
|
51
55
|
}
|
|
52
56
|
return new Uint8Array(bytes);
|
|
53
57
|
}
|
|
@@ -8,6 +8,8 @@ function toPdfX(positioned, itemXPt) {
|
|
|
8
8
|
function toPdfY(positioned, itemYPt) {
|
|
9
9
|
return positioned.yPt + positioned.box.heightPt - itemYPt;
|
|
10
10
|
}
|
|
11
|
+
const BITS_PER_BYTE = 8;
|
|
12
|
+
const BYTE_MASK = 255;
|
|
11
13
|
function writeRgbOperator(writer, color, operator) {
|
|
12
14
|
writer.writeAscii(`${formatNumber(color.r)} ${formatNumber(color.g)} ${formatNumber(color.b)} ${operator}\n`);
|
|
13
15
|
}
|
|
@@ -21,8 +23,8 @@ function encodeGlyphRunToCids(font, text) {
|
|
|
21
23
|
}
|
|
22
24
|
const bytes = new Uint8Array(gids.length * 2);
|
|
23
25
|
gids.forEach((gid, index) => {
|
|
24
|
-
bytes[index * 2] = gid >>
|
|
25
|
-
bytes[index * 2 + 1] = gid &
|
|
26
|
+
bytes[index * 2] = gid >> BITS_PER_BYTE & BYTE_MASK;
|
|
27
|
+
bytes[index * 2 + 1] = gid & BYTE_MASK;
|
|
26
28
|
});
|
|
27
29
|
return bytes;
|
|
28
30
|
}
|
|
@@ -40,13 +42,15 @@ function writeGlyphRun(writer, positioned, item, ctx) {
|
|
|
40
42
|
writer.writeAscii("ET\n");
|
|
41
43
|
}
|
|
42
44
|
function cidBytes(glyphId) {
|
|
43
|
-
return new Uint8Array([glyphId >>
|
|
45
|
+
return new Uint8Array([glyphId >> BITS_PER_BYTE & BYTE_MASK, glyphId & BYTE_MASK]);
|
|
44
46
|
}
|
|
47
|
+
const UTF16_BOM_HIGH_BYTE = 254;
|
|
48
|
+
const UTF16_BOM_LOW_BYTE = 255;
|
|
45
49
|
function utf16BeWithBom(text) {
|
|
46
|
-
const bytes = [
|
|
50
|
+
const bytes = [UTF16_BOM_HIGH_BYTE, UTF16_BOM_LOW_BYTE];
|
|
47
51
|
for (let i = 0; i < text.length; i++) {
|
|
48
52
|
const unit = text.charCodeAt(i);
|
|
49
|
-
bytes.push(unit >>
|
|
53
|
+
bytes.push(unit >> BITS_PER_BYTE & BYTE_MASK, unit & BYTE_MASK);
|
|
50
54
|
}
|
|
51
55
|
return new Uint8Array(bytes);
|
|
52
56
|
}
|
package/dist/math-font-write.cjs
CHANGED
|
@@ -10,9 +10,10 @@ function buildWidthsArray(font, usedGlyphs) {
|
|
|
10
10
|
for (const glyphId of [...usedGlyphs.keys()].sort((a, b) => a - b)) entries.push(require_objects.pdfNum(glyphId), require_objects.pdfArray([require_objects.pdfNum(font.glyphSpaceWidth(glyphId))]));
|
|
11
11
|
return require_objects.pdfArray(entries);
|
|
12
12
|
}
|
|
13
|
+
const GLYPH_SPACE_UNITS_PER_EM = 1e3;
|
|
13
14
|
function buildFontDescriptor(font, fontFileRef) {
|
|
14
15
|
const d = font.descriptor;
|
|
15
|
-
const scale =
|
|
16
|
+
const scale = GLYPH_SPACE_UNITS_PER_EM / d.unitsPerEm;
|
|
16
17
|
return require_objects.pdfDict({
|
|
17
18
|
Type: require_objects.pdfName("FontDescriptor"),
|
|
18
19
|
FontName: require_objects.pdfName("STIXTwoMath-Regular"),
|
package/dist/math-font-write.js
CHANGED
|
@@ -9,9 +9,10 @@ function buildWidthsArray(font, usedGlyphs) {
|
|
|
9
9
|
for (const glyphId of [...usedGlyphs.keys()].sort((a, b) => a - b)) entries.push(pdfNum(glyphId), pdfArray([pdfNum(font.glyphSpaceWidth(glyphId))]));
|
|
10
10
|
return pdfArray(entries);
|
|
11
11
|
}
|
|
12
|
+
const GLYPH_SPACE_UNITS_PER_EM = 1e3;
|
|
12
13
|
function buildFontDescriptor(font, fontFileRef) {
|
|
13
14
|
const d = font.descriptor;
|
|
14
|
-
const scale =
|
|
15
|
+
const scale = GLYPH_SPACE_UNITS_PER_EM / d.unitsPerEm;
|
|
15
16
|
return pdfDict({
|
|
16
17
|
Type: pdfName("FontDescriptor"),
|
|
17
18
|
FontName: pdfName("STIXTwoMath-Regular"),
|
package/dist/math-font.cjs
CHANGED
|
@@ -8,6 +8,15 @@ const require_math_stretch = require("./math-stretch.cjs");
|
|
|
8
8
|
const require_math_table = require("./math-table.cjs");
|
|
9
9
|
let byte_codec = require("byte-codec");
|
|
10
10
|
//#region src/math-font.ts
|
|
11
|
+
const HEAD_UNITS_PER_EM_OFFSET = 18;
|
|
12
|
+
const HEAD_X_MIN_OFFSET = 36;
|
|
13
|
+
const HEAD_Y_MIN_OFFSET = 38;
|
|
14
|
+
const HEAD_X_MAX_OFFSET = 40;
|
|
15
|
+
const HEAD_Y_MAX_OFFSET = 42;
|
|
16
|
+
const HHEA_ASCENDER_OFFSET = 4;
|
|
17
|
+
const HHEA_DESCENDER_OFFSET = 6;
|
|
18
|
+
const OS2_CAP_HEIGHT_OFFSET = 88;
|
|
19
|
+
const GLYPH_SPACE_UNITS_PER_EM = 1e3;
|
|
11
20
|
function toPt(designUnits, unitsPerEm, sizePt) {
|
|
12
21
|
return designUnits / unitsPerEm * sizePt;
|
|
13
22
|
}
|
|
@@ -124,12 +133,12 @@ function loadMathFont() {
|
|
|
124
133
|
const os2Bytes = require_sfnt.sfntTableBytes(sfnt, "OS/2");
|
|
125
134
|
const cffBytes = require_sfnt.sfntTableBytes(sfnt, "CFF ");
|
|
126
135
|
if (headBytes === void 0 || hheaBytes === void 0 || cffBytes === void 0) throw new Error("embedded math font is missing a required sfnt table (head/hhea/CFF )");
|
|
127
|
-
const unitsPerEm = require_sfnt.u16(headBytes,
|
|
128
|
-
const ascentDesignUnits = require_sfnt.i16(hheaBytes,
|
|
129
|
-
const descentDesignUnits = require_sfnt.i16(hheaBytes,
|
|
130
|
-
const bboxMin = [require_sfnt.i16(headBytes,
|
|
131
|
-
const bboxMax = [require_sfnt.i16(headBytes,
|
|
132
|
-
const capHeight = os2Bytes === void 0 ? ascentDesignUnits : require_sfnt.i16(os2Bytes,
|
|
136
|
+
const unitsPerEm = require_sfnt.u16(headBytes, HEAD_UNITS_PER_EM_OFFSET);
|
|
137
|
+
const ascentDesignUnits = require_sfnt.i16(hheaBytes, HHEA_ASCENDER_OFFSET);
|
|
138
|
+
const descentDesignUnits = require_sfnt.i16(hheaBytes, HHEA_DESCENDER_OFFSET);
|
|
139
|
+
const bboxMin = [require_sfnt.i16(headBytes, HEAD_X_MIN_OFFSET), require_sfnt.i16(headBytes, HEAD_Y_MIN_OFFSET)];
|
|
140
|
+
const bboxMax = [require_sfnt.i16(headBytes, HEAD_X_MAX_OFFSET), require_sfnt.i16(headBytes, HEAD_Y_MAX_OFFSET)];
|
|
141
|
+
const capHeight = os2Bytes === void 0 ? ascentDesignUnits : require_sfnt.i16(os2Bytes, OS2_CAP_HEIGHT_OFFSET);
|
|
133
142
|
const cmap = require_cmap_table.buildCmapLookup(sfnt);
|
|
134
143
|
if (cmap === void 0) throw new Error("embedded math font has no readable cmap subtable");
|
|
135
144
|
const hmtx = require_hmtx_table.parseHmtx(sfnt);
|
|
@@ -148,7 +157,7 @@ function loadMathFont() {
|
|
|
148
157
|
italicAngle: 0
|
|
149
158
|
},
|
|
150
159
|
glyphId: (codePoint) => cmap(codePoint),
|
|
151
|
-
glyphSpaceWidth: (glyphId) => hmtx.advanceWidth(glyphId) *
|
|
160
|
+
glyphSpaceWidth: (glyphId) => hmtx.advanceWidth(glyphId) * GLYPH_SPACE_UNITS_PER_EM / unitsPerEm,
|
|
152
161
|
glyphInkBounds: (glyphId) => inkBounds?.bounds(glyphId),
|
|
153
162
|
minConnectorOverlap: math.variants.minConnectorOverlap,
|
|
154
163
|
stretchyConstruction: (codePoint, axis) => {
|
package/dist/math-font.js
CHANGED
|
@@ -7,6 +7,15 @@ import { assembleStretchyGlyph, scaleMathStretchConstruction } from "./math-stre
|
|
|
7
7
|
import { parseMathTable } from "./math-table.js";
|
|
8
8
|
import { base64ToBytes } from "byte-codec";
|
|
9
9
|
//#region src/math-font.ts
|
|
10
|
+
const HEAD_UNITS_PER_EM_OFFSET = 18;
|
|
11
|
+
const HEAD_X_MIN_OFFSET = 36;
|
|
12
|
+
const HEAD_Y_MIN_OFFSET = 38;
|
|
13
|
+
const HEAD_X_MAX_OFFSET = 40;
|
|
14
|
+
const HEAD_Y_MAX_OFFSET = 42;
|
|
15
|
+
const HHEA_ASCENDER_OFFSET = 4;
|
|
16
|
+
const HHEA_DESCENDER_OFFSET = 6;
|
|
17
|
+
const OS2_CAP_HEIGHT_OFFSET = 88;
|
|
18
|
+
const GLYPH_SPACE_UNITS_PER_EM = 1e3;
|
|
10
19
|
function toPt(designUnits, unitsPerEm, sizePt) {
|
|
11
20
|
return designUnits / unitsPerEm * sizePt;
|
|
12
21
|
}
|
|
@@ -123,12 +132,12 @@ function loadMathFont() {
|
|
|
123
132
|
const os2Bytes = sfntTableBytes(sfnt, "OS/2");
|
|
124
133
|
const cffBytes = sfntTableBytes(sfnt, "CFF ");
|
|
125
134
|
if (headBytes === void 0 || hheaBytes === void 0 || cffBytes === void 0) throw new Error("embedded math font is missing a required sfnt table (head/hhea/CFF )");
|
|
126
|
-
const unitsPerEm = u16(headBytes,
|
|
127
|
-
const ascentDesignUnits = i16(hheaBytes,
|
|
128
|
-
const descentDesignUnits = i16(hheaBytes,
|
|
129
|
-
const bboxMin = [i16(headBytes,
|
|
130
|
-
const bboxMax = [i16(headBytes,
|
|
131
|
-
const capHeight = os2Bytes === void 0 ? ascentDesignUnits : i16(os2Bytes,
|
|
135
|
+
const unitsPerEm = u16(headBytes, HEAD_UNITS_PER_EM_OFFSET);
|
|
136
|
+
const ascentDesignUnits = i16(hheaBytes, HHEA_ASCENDER_OFFSET);
|
|
137
|
+
const descentDesignUnits = i16(hheaBytes, HHEA_DESCENDER_OFFSET);
|
|
138
|
+
const bboxMin = [i16(headBytes, HEAD_X_MIN_OFFSET), i16(headBytes, HEAD_Y_MIN_OFFSET)];
|
|
139
|
+
const bboxMax = [i16(headBytes, HEAD_X_MAX_OFFSET), i16(headBytes, HEAD_Y_MAX_OFFSET)];
|
|
140
|
+
const capHeight = os2Bytes === void 0 ? ascentDesignUnits : i16(os2Bytes, OS2_CAP_HEIGHT_OFFSET);
|
|
132
141
|
const cmap = buildCmapLookup(sfnt);
|
|
133
142
|
if (cmap === void 0) throw new Error("embedded math font has no readable cmap subtable");
|
|
134
143
|
const hmtx = parseHmtx(sfnt);
|
|
@@ -147,7 +156,7 @@ function loadMathFont() {
|
|
|
147
156
|
italicAngle: 0
|
|
148
157
|
},
|
|
149
158
|
glyphId: (codePoint) => cmap(codePoint),
|
|
150
|
-
glyphSpaceWidth: (glyphId) => hmtx.advanceWidth(glyphId) *
|
|
159
|
+
glyphSpaceWidth: (glyphId) => hmtx.advanceWidth(glyphId) * GLYPH_SPACE_UNITS_PER_EM / unitsPerEm,
|
|
151
160
|
glyphInkBounds: (glyphId) => inkBounds?.bounds(glyphId),
|
|
152
161
|
minConnectorOverlap: math.variants.minConnectorOverlap,
|
|
153
162
|
stretchyConstruction: (codePoint, axis) => {
|