pdf-parser.js 5.2.29 → 5.3.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/dist/{afm-widths-BHD2HZIL.cjs → afm-widths-C6U0SQj9.cjs} +5 -1448
- package/dist/{afm-widths-B_IGbGky.js → afm-widths-p3UfaXme.js} +3 -1398
- package/dist/afm-widths.cjs +1 -1
- package/dist/afm-widths.js +1 -1
- package/dist/annotations.d.cts +3 -3
- package/dist/annotations.d.ts +3 -3
- package/dist/attachments.d.cts +2 -2
- package/dist/attachments.d.ts +2 -2
- package/dist/builtin-encoding.cjs +4 -3
- package/dist/builtin-encoding.js +2 -1
- package/dist/cmap.d.cts +1 -1
- package/dist/cmap.d.ts +1 -1
- package/dist/content-read.d.cts +1 -1
- package/dist/content-read.d.ts +1 -1
- package/dist/content-write.cjs +1 -1
- package/dist/content-write.d.cts +1 -1
- package/dist/content-write.d.ts +1 -1
- package/dist/content-write.js +1 -1
- package/dist/diagnostics-C9FxfZ6H.d.cts +22 -0
- package/dist/diagnostics-C9FxfZ6H.d.ts +22 -0
- package/dist/diagnostics.d.cts +1 -21
- package/dist/diagnostics.d.ts +1 -21
- package/dist/document.d.cts +1 -1
- package/dist/document.d.ts +1 -1
- package/dist/{embedded-font-ByD7ZiQS.d.ts → embedded-font-CQZbTTDM.d.ts} +1 -1
- package/dist/{embedded-font-DgVBedw6.d.cts → embedded-font-CqePfvrl.d.cts} +1 -1
- package/dist/embedded-font-write.d.cts +1 -1
- package/dist/embedded-font-write.d.ts +1 -1
- package/dist/embedded-font.cjs +2 -2
- package/dist/embedded-font.d.cts +1 -1
- package/dist/embedded-font.d.ts +1 -1
- package/dist/embedded-font.js +2 -2
- package/dist/encoding-glyph-unicode.cjs +353 -0
- package/dist/encoding-glyph-unicode.d.cts +4 -0
- package/dist/encoding-glyph-unicode.d.ts +4 -0
- package/dist/encoding-glyph-unicode.js +352 -0
- package/dist/encoding-standard-tables.cjs +531 -0
- package/dist/encoding-standard-tables.d.cts +7 -0
- package/dist/encoding-standard-tables.d.ts +7 -0
- package/dist/encoding-standard-tables.js +527 -0
- package/dist/encoding-symbol-tables.cjs +531 -0
- package/dist/encoding-symbol-tables.d.cts +7 -0
- package/dist/encoding-symbol-tables.d.ts +7 -0
- package/dist/encoding-symbol-tables.js +527 -0
- package/dist/encoding.cjs +1 -9
- package/dist/encoding.d.cts +1 -9
- package/dist/encoding.d.ts +1 -9
- package/dist/encoding.js +2 -2
- package/dist/encrypt.d.cts +1 -1
- package/dist/encrypt.d.ts +1 -1
- package/dist/filters.d.cts +1 -1
- package/dist/filters.d.ts +1 -1
- package/dist/font-read.cjs +4 -3
- package/dist/font-read.d.cts +2 -2
- package/dist/font-read.d.ts +2 -2
- package/dist/font-read.js +2 -1
- package/dist/font-registry.d.cts +1 -1
- package/dist/font-registry.d.ts +1 -1
- package/dist/form.d.cts +2 -2
- package/dist/form.d.ts +2 -2
- package/dist/gdef-table-D0Hzn4KD.d.cts +15 -0
- package/dist/gdef-table-DL0V8wEZ.d.ts +15 -0
- package/dist/gdef-table.d.cts +1 -14
- package/dist/gdef-table.d.ts +1 -14
- package/dist/glyf-contours.d.cts +12 -1
- package/dist/glyf-contours.d.ts +12 -1
- package/dist/gsub-context.cjs +13 -0
- package/dist/gsub-context.d.cts +34 -0
- package/dist/gsub-context.d.ts +34 -0
- package/dist/gsub-context.js +2 -0
- package/dist/gsub-table-BDpJWqpf.d.ts +52 -0
- package/dist/gsub-table-D6niKeLi.js +556 -0
- package/dist/gsub-table-DW7Wmi9V.d.cts +52 -0
- package/dist/gsub-table-hFfYmf1W.cjs +741 -0
- package/dist/gsub-table.cjs +21 -556
- package/dist/gsub-table.d.cts +2 -2
- package/dist/gsub-table.d.ts +2 -2
- package/dist/gsub-table.js +2 -554
- package/dist/images-read.d.cts +2 -2
- package/dist/images-read.d.ts +2 -2
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/interpret-CqXdXgkY.cjs +712 -0
- package/dist/interpret-aWWhdIzr.js +677 -0
- package/dist/interpret-colors.cjs +6 -0
- package/dist/interpret-colors.d.cts +9 -0
- package/dist/interpret-colors.d.ts +9 -0
- package/dist/interpret-colors.js +2 -0
- package/dist/interpret-marked.cjs +25 -0
- package/dist/interpret-marked.d.cts +11 -0
- package/dist/interpret-marked.d.ts +11 -0
- package/dist/interpret-marked.js +23 -0
- package/dist/interpret-shapes.cjs +212 -0
- package/dist/interpret-shapes.d.cts +32 -0
- package/dist/interpret-shapes.d.ts +32 -0
- package/dist/interpret-shapes.js +199 -0
- package/dist/interpret-types.cjs +0 -0
- package/dist/interpret-types.d.cts +123 -0
- package/dist/interpret-types.d.ts +123 -0
- package/dist/interpret-types.js +0 -0
- package/dist/interpret.cjs +3 -887
- package/dist/interpret.d.cts +5 -116
- package/dist/interpret.d.ts +5 -116
- package/dist/interpret.js +2 -887
- package/dist/math-font.cjs +1 -1
- package/dist/math-font.js +1 -1
- package/dist/measure.cjs +1 -1
- package/dist/measure.js +1 -1
- package/dist/names.d.cts +2 -2
- package/dist/names.d.ts +2 -2
- package/dist/navigation.d.cts +2 -2
- package/dist/navigation.d.ts +2 -2
- package/dist/optional-content.d.cts +2 -2
- package/dist/optional-content.d.ts +2 -2
- package/dist/ot-layout-common-BcsGRFBS.d.cts +10 -0
- package/dist/ot-layout-common-BcsGRFBS.d.ts +10 -0
- package/dist/ot-layout-common.d.cts +1 -9
- package/dist/ot-layout-common.d.ts +1 -9
- package/dist/parse.d.cts +1 -1
- package/dist/parse.d.ts +1 -1
- package/dist/predictors.d.cts +1 -1
- package/dist/predictors.d.ts +1 -1
- package/dist/raster-Cdm3idP_.js +794 -0
- package/dist/raster-EG2KYRZ0.cjs +829 -0
- package/dist/raster-text.cjs +5 -0
- package/dist/raster-text.d.cts +20 -0
- package/dist/raster-text.d.ts +20 -0
- package/dist/raster-text.js +2 -0
- package/dist/raster.cjs +4 -795
- package/dist/raster.d.cts +17 -6
- package/dist/raster.d.ts +17 -6
- package/dist/raster.js +2 -792
- package/dist/read-convert.cjs +310 -0
- package/dist/read-convert.d.cts +58 -0
- package/dist/read-convert.d.ts +58 -0
- package/dist/read-convert.js +295 -0
- package/dist/read.cjs +5 -293
- package/dist/read.d.cts +1 -1
- package/dist/read.d.ts +1 -1
- package/dist/read.js +4 -292
- package/dist/structure.d.cts +2 -2
- package/dist/structure.d.ts +2 -2
- package/dist/winansi.cjs +1 -1
- package/dist/winansi.js +1 -1
- package/dist/write-annotations.cjs +132 -0
- package/dist/write-annotations.d.cts +29 -0
- package/dist/write-annotations.d.ts +29 -0
- package/dist/write-annotations.js +121 -0
- package/dist/write-font-objects.cjs +76 -0
- package/dist/write-font-objects.d.cts +35 -0
- package/dist/write-font-objects.d.ts +35 -0
- package/dist/write-font-objects.js +75 -0
- package/dist/write-form.cjs +91 -0
- package/dist/write-form.d.cts +19 -0
- package/dist/write-form.d.ts +19 -0
- package/dist/write-form.js +89 -0
- package/dist/write-images.cjs +148 -0
- package/dist/write-images.d.cts +25 -0
- package/dist/write-images.d.ts +25 -0
- package/dist/write-images.js +140 -0
- package/dist/write-outline.cjs +46 -0
- package/dist/write-outline.d.cts +18 -0
- package/dist/write-outline.d.ts +18 -0
- package/dist/write-outline.js +45 -0
- package/dist/write-page-emit.cjs +97 -0
- package/dist/write-page-emit.d.cts +63 -0
- package/dist/write-page-emit.d.ts +63 -0
- package/dist/write-page-emit.js +96 -0
- package/dist/write-pages.cjs +37 -0
- package/dist/write-pages.d.cts +21 -0
- package/dist/write-pages.d.ts +21 -0
- package/dist/write-pages.js +36 -0
- package/dist/write-strings.cjs +41 -0
- package/dist/write-strings.d.cts +9 -0
- package/dist/write-strings.d.ts +9 -0
- package/dist/write-strings.js +37 -0
- package/dist/write.cjs +53 -553
- package/dist/write.d.cts +1 -1
- package/dist/write.d.ts +1 -1
- package/dist/write.js +49 -549
- package/dist/xref.d.cts +1 -1
- package/dist/xref.d.ts +1 -1
- package/package.json +2 -2
- package/dist/glyf-contours-B1PsI9oA.d.ts +0 -13
- package/dist/glyf-contours-NHBpgks-.d.cts +0 -13
- package/dist/gsub-table-Bm9kSMzk.d.cts +0 -16
- package/dist/gsub-table-CdfESH2-.d.ts +0 -16
package/dist/gsub-table.cjs
CHANGED
|
@@ -1,557 +1,22 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const LANG_SYS_FEATURE_INDEX_COUNT_OFFSET = 4;
|
|
24
|
-
const FEATURE_HEADER_SIZE = 4;
|
|
25
|
-
const LOOKUP_HEADER_SIZE = 6;
|
|
26
|
-
const LOOKUP_HEADER_SUBTABLE_COUNT_OFFSET = 4;
|
|
27
|
-
const LOOKUP_TYPE_SINGLE_SUBST = 1;
|
|
28
|
-
const LOOKUP_TYPE_LIGATURE_SUBST = 4;
|
|
29
|
-
const LOOKUP_TYPE_CONTEXT_SUBST = 5;
|
|
30
|
-
const LOOKUP_TYPE_CHAIN_CONTEXT_SUBST = 6;
|
|
31
|
-
const LOOKUP_TYPE_EXTENSION_SUBST = 7;
|
|
32
|
-
const EXTENSION_SUBST_HEADER_SIZE = 8;
|
|
33
|
-
const EXTENSION_SUBST_OFFSET_FIELD_OFFSET = 4;
|
|
34
|
-
const BITS_PER_BYTE = 8;
|
|
35
|
-
const BYTE_MASK = 255;
|
|
36
|
-
const SUBST_FORMAT_AND_COVERAGE_SIZE = 4;
|
|
37
|
-
const LOOKUP_FLAG_IGNORE_BASE_GLYPHS = 2;
|
|
38
|
-
const LOOKUP_FLAG_IGNORE_LIGATURES = 4;
|
|
39
|
-
const LOOKUP_FLAG_IGNORE_MARKS = 8;
|
|
40
|
-
const LOOKUP_FLAG_USE_MARK_FILTERING_SET = 16;
|
|
41
|
-
const LOOKUP_FLAG_MARK_ATTACHMENT_TYPE = 65280;
|
|
42
|
-
const MAX_LOOKUP_NESTING_DEPTH = 6;
|
|
43
|
-
const PREFERRED_SCRIPT_TAGS = ["latn", "DFLT"];
|
|
44
|
-
function readTag(bytes, offset) {
|
|
45
|
-
return String.fromCharCode(require_sfnt.u16(bytes, offset) >> BITS_PER_BYTE, require_sfnt.u16(bytes, offset) & BYTE_MASK, require_sfnt.u16(bytes, offset + 2) >> BITS_PER_BYTE, require_sfnt.u16(bytes, offset + 2) & BYTE_MASK);
|
|
46
|
-
}
|
|
47
|
-
function glyphSkipper(lookupFlag, markFilteringSet, gdef) {
|
|
48
|
-
if (gdef === void 0 || lookupFlag === 0) return () => false;
|
|
49
|
-
const ignoreBase = (lookupFlag & LOOKUP_FLAG_IGNORE_BASE_GLYPHS) !== 0;
|
|
50
|
-
const ignoreLigatures = (lookupFlag & LOOKUP_FLAG_IGNORE_LIGATURES) !== 0;
|
|
51
|
-
const ignoreMarks = (lookupFlag & LOOKUP_FLAG_IGNORE_MARKS) !== 0;
|
|
52
|
-
const markAttachmentType = (lookupFlag & LOOKUP_FLAG_MARK_ATTACHMENT_TYPE) >> BITS_PER_BYTE;
|
|
53
|
-
const useMarkFilteringSet = (lookupFlag & LOOKUP_FLAG_USE_MARK_FILTERING_SET) !== 0;
|
|
54
|
-
return (glyphId) => {
|
|
55
|
-
const glyphClass = gdef.glyphClass(glyphId);
|
|
56
|
-
if (ignoreBase && glyphClass === 1) return true;
|
|
57
|
-
if (ignoreLigatures && glyphClass === 2) return true;
|
|
58
|
-
if (glyphClass !== 3) return false;
|
|
59
|
-
if (ignoreMarks) return true;
|
|
60
|
-
if (markAttachmentType !== 0 && gdef.markAttachClass(glyphId) !== markAttachmentType) return true;
|
|
61
|
-
return useMarkFilteringSet && !gdef.markFilteringSetCovers(markFilteringSet, glyphId);
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function nextVisibleSlot(slots, from, skip) {
|
|
65
|
-
for (let i = Math.max(from, 0); i < slots.length; i++) if (!skip(slots[i].glyphId)) return i;
|
|
66
|
-
}
|
|
67
|
-
function prevVisibleSlot(slots, before, skip) {
|
|
68
|
-
for (let i = Math.min(before, slots.length) - 1; i >= 0; i--) if (!skip(slots[i].glyphId)) return i;
|
|
69
|
-
}
|
|
70
|
-
const SINGLE_SUBST_FORMAT_1_SIZE = 6;
|
|
71
|
-
function parseSingleSubstFormat1(bytes, subtableOffset, skip) {
|
|
72
|
-
if (!require_sfnt.hasBytes(bytes, subtableOffset, SINGLE_SUBST_FORMAT_1_SIZE)) return;
|
|
73
|
-
const coverage = require_ot_layout_common.parseCoverage(bytes, subtableOffset + require_sfnt.u16(bytes, subtableOffset + 2));
|
|
74
|
-
if (coverage === void 0) return;
|
|
75
|
-
const delta = require_sfnt.i16(bytes, subtableOffset + SUBST_FORMAT_AND_COVERAGE_SIZE);
|
|
76
|
-
return (slots, index) => {
|
|
77
|
-
const slot = slots[index];
|
|
78
|
-
if (skip(slot.glyphId)) return;
|
|
79
|
-
if (coverage.coverageIndex(slot.glyphId) === void 0) return;
|
|
80
|
-
return {
|
|
81
|
-
consumed: 1,
|
|
82
|
-
replacement: [{
|
|
83
|
-
glyphId: slot.glyphId + delta,
|
|
84
|
-
span: slot.span
|
|
85
|
-
}]
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
const SINGLE_SUBST_FORMAT_2_HEADER_SIZE = 6;
|
|
90
|
-
function parseSingleSubstFormat2(bytes, subtableOffset, skip) {
|
|
91
|
-
if (!require_sfnt.hasBytes(bytes, subtableOffset, SINGLE_SUBST_FORMAT_2_HEADER_SIZE)) return;
|
|
92
|
-
const coverage = require_ot_layout_common.parseCoverage(bytes, subtableOffset + require_sfnt.u16(bytes, subtableOffset + 2));
|
|
93
|
-
if (coverage === void 0) return;
|
|
94
|
-
const glyphCount = require_sfnt.u16(bytes, subtableOffset + SUBST_FORMAT_AND_COVERAGE_SIZE);
|
|
95
|
-
const substitutesOffset = subtableOffset + SINGLE_SUBST_FORMAT_2_HEADER_SIZE;
|
|
96
|
-
if (!require_sfnt.hasBytes(bytes, substitutesOffset, glyphCount * 2)) return;
|
|
97
|
-
return (slots, index) => {
|
|
98
|
-
const slot = slots[index];
|
|
99
|
-
if (skip(slot.glyphId)) return;
|
|
100
|
-
const coverageIndex = coverage.coverageIndex(slot.glyphId);
|
|
101
|
-
if (coverageIndex === void 0 || coverageIndex >= glyphCount) return;
|
|
102
|
-
return {
|
|
103
|
-
consumed: 1,
|
|
104
|
-
replacement: [{
|
|
105
|
-
glyphId: require_sfnt.u16(bytes, substitutesOffset + coverageIndex * 2),
|
|
106
|
-
span: slot.span
|
|
107
|
-
}]
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
const LIGATURE_SUBST_FORMAT_1_HEADER_SIZE = 6;
|
|
112
|
-
const LIGATURE_SET_HEADER_SIZE = 2;
|
|
113
|
-
const LIGATURE_HEADER_PREFIX_SIZE = 4;
|
|
114
|
-
function parseLigatureSubstFormat1(bytes, subtableOffset, skip) {
|
|
115
|
-
if (!require_sfnt.hasBytes(bytes, subtableOffset, LIGATURE_SUBST_FORMAT_1_HEADER_SIZE)) return;
|
|
116
|
-
const coverage = require_ot_layout_common.parseCoverage(bytes, subtableOffset + require_sfnt.u16(bytes, subtableOffset + 2));
|
|
117
|
-
if (coverage === void 0) return;
|
|
118
|
-
const ligSetCount = require_sfnt.u16(bytes, subtableOffset + SUBST_FORMAT_AND_COVERAGE_SIZE);
|
|
119
|
-
const ligSetOffsetsOffset = subtableOffset + LIGATURE_SUBST_FORMAT_1_HEADER_SIZE;
|
|
120
|
-
if (!require_sfnt.hasBytes(bytes, ligSetOffsetsOffset, ligSetCount * 2)) return;
|
|
121
|
-
return (slots, index) => {
|
|
122
|
-
const first = slots[index];
|
|
123
|
-
if (skip(first.glyphId)) return;
|
|
124
|
-
const coverageIndex = coverage.coverageIndex(first.glyphId);
|
|
125
|
-
if (coverageIndex === void 0 || coverageIndex >= ligSetCount) return;
|
|
126
|
-
const ligSetOffset = subtableOffset + require_sfnt.u16(bytes, ligSetOffsetsOffset + coverageIndex * 2);
|
|
127
|
-
if (!require_sfnt.hasBytes(bytes, ligSetOffset, LIGATURE_SET_HEADER_SIZE)) return;
|
|
128
|
-
const ligatureCount = require_sfnt.u16(bytes, ligSetOffset);
|
|
129
|
-
const ligatureOffsetsOffset = ligSetOffset + LIGATURE_SET_HEADER_SIZE;
|
|
130
|
-
if (!require_sfnt.hasBytes(bytes, ligatureOffsetsOffset, ligatureCount * 2)) return;
|
|
131
|
-
for (let i = 0; i < ligatureCount; i++) {
|
|
132
|
-
const ligatureOffset = ligSetOffset + require_sfnt.u16(bytes, ligatureOffsetsOffset + i * 2);
|
|
133
|
-
if (!require_sfnt.hasBytes(bytes, ligatureOffset, LIGATURE_HEADER_PREFIX_SIZE)) continue;
|
|
134
|
-
const ligatureGlyph = require_sfnt.u16(bytes, ligatureOffset);
|
|
135
|
-
const componentCount = require_sfnt.u16(bytes, ligatureOffset + 2);
|
|
136
|
-
if (componentCount === 0) continue;
|
|
137
|
-
const componentsOffset = ligatureOffset + LIGATURE_HEADER_PREFIX_SIZE;
|
|
138
|
-
if (!require_sfnt.hasBytes(bytes, componentsOffset, (componentCount - 1) * 2)) continue;
|
|
139
|
-
const matchedSlots = [index];
|
|
140
|
-
let cursor = index;
|
|
141
|
-
let matches = true;
|
|
142
|
-
for (let c = 1; c < componentCount; c++) {
|
|
143
|
-
const next = nextVisibleSlot(slots, cursor + 1, skip);
|
|
144
|
-
if (next === void 0 || slots[next].glyphId !== require_sfnt.u16(bytes, componentsOffset + (c - 1) * 2)) {
|
|
145
|
-
matches = false;
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
matchedSlots.push(next);
|
|
149
|
-
cursor = next;
|
|
150
|
-
}
|
|
151
|
-
if (!matches) continue;
|
|
152
|
-
const lastSlot = matchedSlots[matchedSlots.length - 1];
|
|
153
|
-
let windowSpan = 0;
|
|
154
|
-
const retained = [];
|
|
155
|
-
for (let s = index; s <= lastSlot; s++) {
|
|
156
|
-
windowSpan += slots[s].span;
|
|
157
|
-
if (skip(slots[s].glyphId)) retained.push({
|
|
158
|
-
glyphId: slots[s].glyphId,
|
|
159
|
-
span: 0
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
consumed: lastSlot - index + 1,
|
|
164
|
-
replacement: [{
|
|
165
|
-
glyphId: ligatureGlyph,
|
|
166
|
-
span: windowSpan
|
|
167
|
-
}, ...retained]
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
function matchContextualRule(slots, index, skip, backtrack, inputTests, lookahead) {
|
|
173
|
-
const inputSlots = [index];
|
|
174
|
-
let cursor = index;
|
|
175
|
-
for (const test of inputTests) {
|
|
176
|
-
const next = nextVisibleSlot(slots, cursor + 1, skip);
|
|
177
|
-
if (next === void 0 || !test(slots[next].glyphId)) return;
|
|
178
|
-
inputSlots.push(next);
|
|
179
|
-
cursor = next;
|
|
180
|
-
}
|
|
181
|
-
let back = index;
|
|
182
|
-
for (let b = backtrack.length - 1; b >= 0; b--) {
|
|
183
|
-
const previous = prevVisibleSlot(slots, back, skip);
|
|
184
|
-
if (previous === void 0 || !backtrack[b](slots[previous].glyphId)) return;
|
|
185
|
-
back = previous;
|
|
186
|
-
}
|
|
187
|
-
let ahead = inputSlots[inputSlots.length - 1];
|
|
188
|
-
for (const test of lookahead) {
|
|
189
|
-
const next = nextVisibleSlot(slots, ahead + 1, skip);
|
|
190
|
-
if (next === void 0 || !test(slots[next].glyphId)) return;
|
|
191
|
-
ahead = next;
|
|
192
|
-
}
|
|
193
|
-
return inputSlots;
|
|
194
|
-
}
|
|
195
|
-
function applyContextualRule(slots, inputSlots, records, lookupOf, skip, depth) {
|
|
196
|
-
const first = inputSlots[0];
|
|
197
|
-
const last = inputSlots[inputSlots.length - 1];
|
|
198
|
-
const window = [];
|
|
199
|
-
for (let s = first; s <= last; s++) window.push({
|
|
200
|
-
glyphId: slots[s].glyphId,
|
|
201
|
-
span: slots[s].span
|
|
202
|
-
});
|
|
203
|
-
for (const record of records) {
|
|
204
|
-
const lookup = lookupOf(record.lookupIndex);
|
|
205
|
-
if (lookup === void 0 || record.sequenceIndex >= inputSlots.length || depth >= MAX_LOOKUP_NESTING_DEPTH) return;
|
|
206
|
-
const target = visibleInputSlot(window, record.sequenceIndex, skip);
|
|
207
|
-
if (target !== void 0) {
|
|
208
|
-
const application = applyLookupAtSlot(window, target, lookup, depth + 1);
|
|
209
|
-
if (application !== void 0) window.splice(target, application.consumed, ...application.replacement);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
consumed: last - first + 1,
|
|
214
|
-
replacement: window
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
function visibleInputSlot(window, position, skip) {
|
|
218
|
-
let seen = 0;
|
|
219
|
-
for (let i = 0; i < window.length; i++) {
|
|
220
|
-
if (skip(window[i].glyphId)) continue;
|
|
221
|
-
if (seen === position) return i;
|
|
222
|
-
seen += 1;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
function applyLookupAtSlot(slots, index, lookup, depth) {
|
|
226
|
-
for (const subtable of lookup.subtables) {
|
|
227
|
-
const application = subtable(slots, index, depth);
|
|
228
|
-
if (application !== void 0) return application;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
const SUBST_LOOKUP_RECORD_SIZE = 4;
|
|
232
|
-
function readSubstLookupRecords(bytes, offset, count) {
|
|
233
|
-
if (!require_sfnt.hasBytes(bytes, offset, count * SUBST_LOOKUP_RECORD_SIZE)) return;
|
|
234
|
-
const records = [];
|
|
235
|
-
for (let i = 0; i < count; i++) {
|
|
236
|
-
const recordOffset = offset + i * SUBST_LOOKUP_RECORD_SIZE;
|
|
237
|
-
records.push({
|
|
238
|
-
sequenceIndex: require_sfnt.u16(bytes, recordOffset),
|
|
239
|
-
lookupIndex: require_sfnt.u16(bytes, recordOffset + 2)
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
return records;
|
|
243
|
-
}
|
|
244
|
-
function parseFormat3Rule(bytes, subtableOffset, chained) {
|
|
245
|
-
let offset = subtableOffset + 2;
|
|
246
|
-
const backtrack = [];
|
|
247
|
-
const input = [];
|
|
248
|
-
const lookahead = [];
|
|
249
|
-
const readCoverageArray = () => {
|
|
250
|
-
if (!require_sfnt.hasBytes(bytes, offset, 2)) return;
|
|
251
|
-
const count = require_sfnt.u16(bytes, offset);
|
|
252
|
-
offset += 2;
|
|
253
|
-
if (!require_sfnt.hasBytes(bytes, offset, count * 2)) return;
|
|
254
|
-
const coverages = [];
|
|
255
|
-
for (let i = 0; i < count; i++) {
|
|
256
|
-
const coverageOffset = require_sfnt.u16(bytes, offset + i * 2);
|
|
257
|
-
if (coverageOffset === 0) return;
|
|
258
|
-
const coverage = require_ot_layout_common.parseCoverage(bytes, subtableOffset + coverageOffset);
|
|
259
|
-
if (coverage === void 0) return;
|
|
260
|
-
coverages.push(coverage);
|
|
261
|
-
}
|
|
262
|
-
offset += count * 2;
|
|
263
|
-
return coverages;
|
|
264
|
-
};
|
|
265
|
-
if (chained) {
|
|
266
|
-
const backtracks = readCoverageArray();
|
|
267
|
-
if (backtracks === void 0) return;
|
|
268
|
-
backtrack.push(...backtracks);
|
|
269
|
-
}
|
|
270
|
-
{
|
|
271
|
-
const inputs = readCoverageArray();
|
|
272
|
-
if (inputs === void 0 || inputs.length === 0) return;
|
|
273
|
-
input.push(...inputs);
|
|
274
|
-
}
|
|
275
|
-
if (chained) {
|
|
276
|
-
const lookaheads = readCoverageArray();
|
|
277
|
-
if (lookaheads === void 0) return;
|
|
278
|
-
lookahead.push(...lookaheads);
|
|
279
|
-
}
|
|
280
|
-
if (!require_sfnt.hasBytes(bytes, offset, 2)) return;
|
|
281
|
-
const substCount = require_sfnt.u16(bytes, offset);
|
|
282
|
-
const records = readSubstLookupRecords(bytes, offset + 2, substCount);
|
|
283
|
-
if (records === void 0) return;
|
|
284
|
-
return {
|
|
285
|
-
backtrack,
|
|
286
|
-
input,
|
|
287
|
-
lookahead,
|
|
288
|
-
records
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function format3Subtable(rule, skip, lookupOf) {
|
|
292
|
-
const inputRest = [];
|
|
293
|
-
for (let i = 1; i < rule.input.length; i++) {
|
|
294
|
-
const coverage = rule.input[i];
|
|
295
|
-
inputRest.push((glyphId) => coverage.coverageIndex(glyphId) !== void 0);
|
|
296
|
-
}
|
|
297
|
-
const backtrack = rule.backtrack.map((coverage) => (glyphId) => coverage.coverageIndex(glyphId) !== void 0);
|
|
298
|
-
const lookahead = rule.lookahead.map((coverage) => (glyphId) => coverage.coverageIndex(glyphId) !== void 0);
|
|
299
|
-
return (slots, index, depth) => {
|
|
300
|
-
const slot = slots[index];
|
|
301
|
-
if (skip(slot.glyphId)) return;
|
|
302
|
-
if (rule.input[0].coverageIndex(slot.glyphId) === void 0) return;
|
|
303
|
-
const inputSlots = matchContextualRule(slots, index, skip, backtrack, inputRest, lookahead);
|
|
304
|
-
if (inputSlots === void 0) return;
|
|
305
|
-
return applyContextualRule(slots, inputSlots, rule.records, lookupOf, skip, depth);
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
function readSequenceRule(bytes, ruleOffset, chained) {
|
|
309
|
-
let offset = ruleOffset;
|
|
310
|
-
const readU16 = () => {
|
|
311
|
-
if (!require_sfnt.hasBytes(bytes, offset, 2)) return;
|
|
312
|
-
const value = require_sfnt.u16(bytes, offset);
|
|
313
|
-
offset += 2;
|
|
314
|
-
return value;
|
|
315
|
-
};
|
|
316
|
-
const readArray = () => {
|
|
317
|
-
const count = readU16();
|
|
318
|
-
if (count === void 0 || !require_sfnt.hasBytes(bytes, offset, count * 2)) return;
|
|
319
|
-
const values = [];
|
|
320
|
-
for (let i = 0; i < count; i++) values.push(require_sfnt.u16(bytes, offset + i * 2));
|
|
321
|
-
offset += count * 2;
|
|
322
|
-
return values;
|
|
323
|
-
};
|
|
324
|
-
const backtrack = chained ? readArray() : [];
|
|
325
|
-
const glyphCount = readU16();
|
|
326
|
-
if (backtrack === void 0 || glyphCount === void 0 || glyphCount === 0 || !require_sfnt.hasBytes(bytes, offset, (glyphCount - 1) * 2)) return;
|
|
327
|
-
const input = [];
|
|
328
|
-
for (let i = 0; i < glyphCount - 1; i++) input.push(require_sfnt.u16(bytes, offset + i * 2));
|
|
329
|
-
offset += (glyphCount - 1) * 2;
|
|
330
|
-
const lookahead = chained ? readArray() : [];
|
|
331
|
-
const substCount = readU16();
|
|
332
|
-
if (lookahead === void 0 || substCount === void 0) return;
|
|
333
|
-
const records = readSubstLookupRecords(bytes, offset, substCount);
|
|
334
|
-
if (records === void 0) return;
|
|
335
|
-
return {
|
|
336
|
-
backtrack,
|
|
337
|
-
input,
|
|
338
|
-
lookahead,
|
|
339
|
-
records
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
function sequenceSubtable(bytes, subtableOffset, coverage, setCount, setOffsetsOffset, chained, access, skip, lookupOf) {
|
|
343
|
-
const readSet = (entryGlyphId) => {
|
|
344
|
-
const setIndex = access.setIndexOf(entryGlyphId);
|
|
345
|
-
if (setIndex === void 0 || setIndex >= setCount) return [];
|
|
346
|
-
const setOffset = require_sfnt.u16(bytes, setOffsetsOffset + setIndex * 2);
|
|
347
|
-
if (setOffset === 0) return [];
|
|
348
|
-
const ruleSetOffset = subtableOffset + setOffset;
|
|
349
|
-
if (!require_sfnt.hasBytes(bytes, ruleSetOffset, 2)) return [];
|
|
350
|
-
const ruleCount = require_sfnt.u16(bytes, ruleSetOffset);
|
|
351
|
-
if (!require_sfnt.hasBytes(bytes, ruleSetOffset + 2, ruleCount * 2)) return [];
|
|
352
|
-
const rules = [];
|
|
353
|
-
for (let i = 0; i < ruleCount; i++) {
|
|
354
|
-
const rule = readSequenceRule(bytes, ruleSetOffset + require_sfnt.u16(bytes, ruleSetOffset + 2 + i * 2), chained);
|
|
355
|
-
if (rule !== void 0) rules.push(rule);
|
|
356
|
-
}
|
|
357
|
-
return rules;
|
|
358
|
-
};
|
|
359
|
-
return (slots, index, depth) => {
|
|
360
|
-
const slot = slots[index];
|
|
361
|
-
if (skip(slot.glyphId)) return;
|
|
362
|
-
if (coverage.coverageIndex(slot.glyphId) === void 0) return;
|
|
363
|
-
for (const rule of readSet(slot.glyphId)) {
|
|
364
|
-
const inputSlots = matchContextualRule(slots, index, skip, rule.backtrack.map(access.backtrackTest), rule.input.map(access.inputTest), rule.lookahead.map(access.lookaheadTest));
|
|
365
|
-
if (inputSlots !== void 0) return applyContextualRule(slots, inputSlots, rule.records, lookupOf, skip, depth);
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
function parseSubtable(bytes, lookupType, subtableOffset, skip, lookupOf) {
|
|
370
|
-
if (lookupType === LOOKUP_TYPE_EXTENSION_SUBST) {
|
|
371
|
-
if (!require_sfnt.hasBytes(bytes, subtableOffset, EXTENSION_SUBST_HEADER_SIZE) || require_sfnt.u16(bytes, subtableOffset) !== 1) return;
|
|
372
|
-
const extensionLookupType = require_sfnt.u16(bytes, subtableOffset + 2);
|
|
373
|
-
if (extensionLookupType === LOOKUP_TYPE_EXTENSION_SUBST) return;
|
|
374
|
-
return parseSubtable(bytes, extensionLookupType, subtableOffset + require_sfnt.u32(bytes, subtableOffset + EXTENSION_SUBST_OFFSET_FIELD_OFFSET), skip, lookupOf);
|
|
375
|
-
}
|
|
376
|
-
if (lookupType === LOOKUP_TYPE_SINGLE_SUBST) {
|
|
377
|
-
if (!require_sfnt.hasBytes(bytes, subtableOffset, 2)) return;
|
|
378
|
-
const substFormat = require_sfnt.u16(bytes, subtableOffset);
|
|
379
|
-
if (substFormat === 1) return parseSingleSubstFormat1(bytes, subtableOffset, skip);
|
|
380
|
-
if (substFormat === 2) return parseSingleSubstFormat2(bytes, subtableOffset, skip);
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
if (lookupType === LOOKUP_TYPE_LIGATURE_SUBST) {
|
|
384
|
-
if (!require_sfnt.hasBytes(bytes, subtableOffset, 2)) return;
|
|
385
|
-
if (require_sfnt.u16(bytes, subtableOffset) !== 1) return;
|
|
386
|
-
return parseLigatureSubstFormat1(bytes, subtableOffset, skip);
|
|
387
|
-
}
|
|
388
|
-
if (lookupType === LOOKUP_TYPE_CONTEXT_SUBST || lookupType === LOOKUP_TYPE_CHAIN_CONTEXT_SUBST) return parseContextualSubtable(bytes, lookupType === LOOKUP_TYPE_CHAIN_CONTEXT_SUBST, subtableOffset, skip, lookupOf);
|
|
389
|
-
}
|
|
390
|
-
function parseContextualSubtable(bytes, chained, subtableOffset, skip, lookupOf) {
|
|
391
|
-
if (!require_sfnt.hasBytes(bytes, subtableOffset, 2)) return;
|
|
392
|
-
const substFormat = require_sfnt.u16(bytes, subtableOffset);
|
|
393
|
-
if (substFormat === 3) {
|
|
394
|
-
const rule = parseFormat3Rule(bytes, subtableOffset, chained);
|
|
395
|
-
return rule === void 0 ? void 0 : format3Subtable(rule, skip, lookupOf);
|
|
396
|
-
}
|
|
397
|
-
if (substFormat === 1) {
|
|
398
|
-
const prefixSize = 6;
|
|
399
|
-
if (!require_sfnt.hasBytes(bytes, subtableOffset, prefixSize)) return;
|
|
400
|
-
const coverage = require_ot_layout_common.parseCoverage(bytes, subtableOffset + require_sfnt.u16(bytes, subtableOffset + 2));
|
|
401
|
-
if (coverage === void 0) return;
|
|
402
|
-
const setCount = require_sfnt.u16(bytes, subtableOffset + SUBST_FORMAT_AND_COVERAGE_SIZE);
|
|
403
|
-
const setOffsetsOffset = subtableOffset + prefixSize;
|
|
404
|
-
if (!require_sfnt.hasBytes(bytes, setOffsetsOffset, setCount * 2)) return;
|
|
405
|
-
const glyphEquality = (expected) => (glyphId) => glyphId === expected;
|
|
406
|
-
return sequenceSubtable(bytes, subtableOffset, coverage, setCount, setOffsetsOffset, chained, {
|
|
407
|
-
setIndexOf: (entryGlyphId) => coverage.coverageIndex(entryGlyphId),
|
|
408
|
-
backtrackTest: glyphEquality,
|
|
409
|
-
inputTest: glyphEquality,
|
|
410
|
-
lookaheadTest: glyphEquality
|
|
411
|
-
}, skip, lookupOf);
|
|
412
|
-
}
|
|
413
|
-
if (substFormat === 2) {
|
|
414
|
-
const prefixSize = chained ? 12 : 8;
|
|
415
|
-
if (!require_sfnt.hasBytes(bytes, subtableOffset, prefixSize)) return;
|
|
416
|
-
const coverage = require_ot_layout_common.parseCoverage(bytes, subtableOffset + require_sfnt.u16(bytes, subtableOffset + 2));
|
|
417
|
-
if (coverage === void 0) return;
|
|
418
|
-
const inputClassDefOffset = chained ? require_sfnt.u16(bytes, subtableOffset + 6) : require_sfnt.u16(bytes, subtableOffset + SUBST_FORMAT_AND_COVERAGE_SIZE);
|
|
419
|
-
const inputClassDef = inputClassDefOffset === 0 ? constantZeroClassDef : require_ot_layout_common.parseClassDef(bytes, subtableOffset + inputClassDefOffset);
|
|
420
|
-
const readAuxClassDef = (offset) => offset === 0 ? constantZeroClassDef : require_ot_layout_common.parseClassDef(bytes, subtableOffset + offset);
|
|
421
|
-
const backtrackClassDef = chained ? readAuxClassDef(require_sfnt.u16(bytes, subtableOffset + SUBST_FORMAT_AND_COVERAGE_SIZE)) : constantZeroClassDef;
|
|
422
|
-
const lookaheadClassDef = chained ? readAuxClassDef(require_sfnt.u16(bytes, subtableOffset + 8)) : constantZeroClassDef;
|
|
423
|
-
if (inputClassDef === void 0 || backtrackClassDef === void 0 || lookaheadClassDef === void 0) return;
|
|
424
|
-
const setCount = require_sfnt.u16(bytes, subtableOffset + prefixSize - 2);
|
|
425
|
-
const setOffsetsOffset = subtableOffset + prefixSize;
|
|
426
|
-
if (!require_sfnt.hasBytes(bytes, setOffsetsOffset, setCount * 2)) return;
|
|
427
|
-
const classEquality = (classDef, expected) => (glyphId) => classDef(glyphId) === expected;
|
|
428
|
-
return sequenceSubtable(bytes, subtableOffset, coverage, setCount, setOffsetsOffset, chained, {
|
|
429
|
-
setIndexOf: (entryGlyphId) => inputClassDef(entryGlyphId),
|
|
430
|
-
backtrackTest: (expected) => classEquality(backtrackClassDef, expected),
|
|
431
|
-
inputTest: (expected) => classEquality(inputClassDef, expected),
|
|
432
|
-
lookaheadTest: (expected) => classEquality(lookaheadClassDef, expected)
|
|
433
|
-
}, skip, lookupOf);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
function findScriptOffset(bytes, scriptListOffset) {
|
|
437
|
-
if (!require_sfnt.hasBytes(bytes, scriptListOffset, 2)) return;
|
|
438
|
-
const scriptCount = require_sfnt.u16(bytes, scriptListOffset);
|
|
439
|
-
const recordsOffset = scriptListOffset + 2;
|
|
440
|
-
if (!require_sfnt.hasBytes(bytes, recordsOffset, scriptCount * SCRIPT_RECORD_SIZE) || scriptCount === 0) return;
|
|
441
|
-
for (const wanted of PREFERRED_SCRIPT_TAGS) for (let i = 0; i < scriptCount; i++) {
|
|
442
|
-
const recordOffset = recordsOffset + i * SCRIPT_RECORD_SIZE;
|
|
443
|
-
if (readTag(bytes, recordOffset) === wanted) return scriptListOffset + require_sfnt.u16(bytes, recordOffset + SCRIPT_RECORD_OFFSET_FIELD_OFFSET);
|
|
444
|
-
}
|
|
445
|
-
return scriptListOffset + require_sfnt.u16(bytes, recordsOffset + SCRIPT_RECORD_OFFSET_FIELD_OFFSET);
|
|
446
|
-
}
|
|
447
|
-
function parseDefaultLangSysFeatureIndices(bytes, scriptOffset) {
|
|
448
|
-
if (!require_sfnt.hasBytes(bytes, scriptOffset, 2)) return [];
|
|
449
|
-
const defaultLangSysOffset = require_sfnt.u16(bytes, scriptOffset);
|
|
450
|
-
if (defaultLangSysOffset === 0) return [];
|
|
451
|
-
const langSysOffset = scriptOffset + defaultLangSysOffset;
|
|
452
|
-
if (!require_sfnt.hasBytes(bytes, langSysOffset, LANG_SYS_HEADER_SIZE)) return [];
|
|
453
|
-
const featureIndexCount = require_sfnt.u16(bytes, langSysOffset + LANG_SYS_FEATURE_INDEX_COUNT_OFFSET);
|
|
454
|
-
const indicesOffset = langSysOffset + LANG_SYS_HEADER_SIZE;
|
|
455
|
-
if (!require_sfnt.hasBytes(bytes, indicesOffset, featureIndexCount * 2)) return [];
|
|
456
|
-
const indices = [];
|
|
457
|
-
for (let i = 0; i < featureIndexCount; i++) indices.push(require_sfnt.u16(bytes, indicesOffset + i * 2));
|
|
458
|
-
return indices;
|
|
459
|
-
}
|
|
460
|
-
function collectLookupIndices(bytes, featureListOffset, featureIndices, featureTags) {
|
|
461
|
-
if (!require_sfnt.hasBytes(bytes, featureListOffset, 2)) return [];
|
|
462
|
-
const featureCount = require_sfnt.u16(bytes, featureListOffset);
|
|
463
|
-
const recordsOffset = featureListOffset + 2;
|
|
464
|
-
if (!require_sfnt.hasBytes(bytes, recordsOffset, featureCount * FEATURE_RECORD_SIZE)) return [];
|
|
465
|
-
const lookupIndices = [];
|
|
466
|
-
const seen = /* @__PURE__ */ new Set();
|
|
467
|
-
for (const featureIndex of featureIndices) {
|
|
468
|
-
if (featureIndex >= featureCount) continue;
|
|
469
|
-
const recordOffset = recordsOffset + featureIndex * FEATURE_RECORD_SIZE;
|
|
470
|
-
if (!featureTags.includes(readTag(bytes, recordOffset))) continue;
|
|
471
|
-
const featureOffset = featureListOffset + require_sfnt.u16(bytes, recordOffset + FEATURE_RECORD_OFFSET_FIELD_OFFSET);
|
|
472
|
-
if (!require_sfnt.hasBytes(bytes, featureOffset, FEATURE_HEADER_SIZE)) continue;
|
|
473
|
-
const lookupIndexCount = require_sfnt.u16(bytes, featureOffset + 2);
|
|
474
|
-
const indicesOffset = featureOffset + FEATURE_HEADER_SIZE;
|
|
475
|
-
if (!require_sfnt.hasBytes(bytes, indicesOffset, lookupIndexCount * 2)) continue;
|
|
476
|
-
for (let i = 0; i < lookupIndexCount; i++) {
|
|
477
|
-
const lookupIndex = require_sfnt.u16(bytes, indicesOffset + i * 2);
|
|
478
|
-
if (!seen.has(lookupIndex)) {
|
|
479
|
-
seen.add(lookupIndex);
|
|
480
|
-
lookupIndices.push(lookupIndex);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
return lookupIndices;
|
|
485
|
-
}
|
|
486
|
-
function buildGsubShaper(font, options = {}) {
|
|
487
|
-
const bytes = require_sfnt.sfntTableBytes(font, "GSUB");
|
|
488
|
-
if (bytes === void 0 || !require_sfnt.hasBytes(bytes, 0, GSUB_HEADER_SIZE) || require_sfnt.u16(bytes, 0) !== 1) return;
|
|
489
|
-
const scriptOffset = findScriptOffset(bytes, require_sfnt.u16(bytes, GSUB_HEADER_SCRIPT_LIST_OFFSET));
|
|
490
|
-
if (scriptOffset === void 0) return;
|
|
491
|
-
const featureTags = [...DEFAULT_GSUB_FEATURE_TAGS, ...options.optInFeatures ?? []];
|
|
492
|
-
const lookupIndices = collectLookupIndices(bytes, require_sfnt.u16(bytes, GSUB_HEADER_FEATURE_LIST_OFFSET), parseDefaultLangSysFeatureIndices(bytes, scriptOffset), featureTags);
|
|
493
|
-
if (lookupIndices.length === 0) return;
|
|
494
|
-
const lookupListOffset = require_sfnt.u16(bytes, GSUB_HEADER_LOOKUP_LIST_OFFSET);
|
|
495
|
-
if (!require_sfnt.hasBytes(bytes, lookupListOffset, 2)) return;
|
|
496
|
-
const lookupCount = require_sfnt.u16(bytes, lookupListOffset);
|
|
497
|
-
const lookupOffsetsOffset = lookupListOffset + 2;
|
|
498
|
-
if (!require_sfnt.hasBytes(bytes, lookupOffsetsOffset, lookupCount * 2)) return;
|
|
499
|
-
const gdef = require_gdef_table.parseGdefTable(font);
|
|
500
|
-
const lookups = [];
|
|
501
|
-
const lookupOf = (lookupIndex) => lookups[lookupIndex];
|
|
502
|
-
for (let i = 0; i < lookupCount; i++) {
|
|
503
|
-
const lookupOffset = lookupListOffset + require_sfnt.u16(bytes, lookupOffsetsOffset + i * 2);
|
|
504
|
-
if (!require_sfnt.hasBytes(bytes, lookupOffset, LOOKUP_HEADER_SIZE)) {
|
|
505
|
-
lookups.push(void 0);
|
|
506
|
-
continue;
|
|
507
|
-
}
|
|
508
|
-
const lookupFlag = require_sfnt.u16(bytes, lookupOffset + 2);
|
|
509
|
-
const lookupType = require_sfnt.u16(bytes, lookupOffset);
|
|
510
|
-
const subTableCount = require_sfnt.u16(bytes, lookupOffset + LOOKUP_HEADER_SUBTABLE_COUNT_OFFSET);
|
|
511
|
-
const subtableOffsetsOffset = lookupOffset + LOOKUP_HEADER_SIZE;
|
|
512
|
-
const markFilteringSetWidth = (lookupFlag & LOOKUP_FLAG_USE_MARK_FILTERING_SET) !== 0 ? 2 : 0;
|
|
513
|
-
if (!require_sfnt.hasBytes(bytes, subtableOffsetsOffset, subTableCount * 2 + markFilteringSetWidth)) {
|
|
514
|
-
lookups.push(void 0);
|
|
515
|
-
continue;
|
|
516
|
-
}
|
|
517
|
-
const skip = glyphSkipper(lookupFlag, markFilteringSetWidth === 0 ? 0 : require_sfnt.u16(bytes, subtableOffsetsOffset + subTableCount * 2), gdef);
|
|
518
|
-
const subtables = [];
|
|
519
|
-
for (let s = 0; s < subTableCount; s++) {
|
|
520
|
-
const subtable = parseSubtable(bytes, lookupType, lookupOffset + require_sfnt.u16(bytes, subtableOffsetsOffset + s * 2), skip, lookupOf);
|
|
521
|
-
if (subtable !== void 0) subtables.push(subtable);
|
|
522
|
-
}
|
|
523
|
-
lookups.push({ subtables });
|
|
524
|
-
}
|
|
525
|
-
const appliedLookups = [];
|
|
526
|
-
for (const lookupIndex of lookupIndices) {
|
|
527
|
-
const lookup = lookupOf(lookupIndex);
|
|
528
|
-
if (lookup !== void 0) appliedLookups.push(lookup);
|
|
529
|
-
}
|
|
530
|
-
if (appliedLookups.every((lookup) => lookup.subtables.length === 0)) return;
|
|
531
|
-
return (glyphIds) => {
|
|
532
|
-
const slots = glyphIds.map((glyphId) => ({
|
|
533
|
-
glyphId,
|
|
534
|
-
span: 1
|
|
535
|
-
}));
|
|
536
|
-
for (const lookup of appliedLookups) {
|
|
537
|
-
let slotIndex = 0;
|
|
538
|
-
while (slotIndex < slots.length) {
|
|
539
|
-
const application = applyLookupAtSlot(slots, slotIndex, lookup, 0);
|
|
540
|
-
if (application === void 0) {
|
|
541
|
-
slotIndex += 1;
|
|
542
|
-
continue;
|
|
543
|
-
}
|
|
544
|
-
slots.splice(slotIndex, application.consumed, ...application.replacement);
|
|
545
|
-
slotIndex += application.replacement.length !== 0 ? application.replacement.length : 1;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
return {
|
|
549
|
-
glyphIds: slots.map((slot) => slot.glyphId),
|
|
550
|
-
spans: slots.map((slot) => slot.span)
|
|
551
|
-
};
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
//#endregion
|
|
555
|
-
exports.DEFAULT_GSUB_FEATURE_TAGS = DEFAULT_GSUB_FEATURE_TAGS;
|
|
556
|
-
exports.GSUB_OPT_IN_FEATURE_TAGS = GSUB_OPT_IN_FEATURE_TAGS;
|
|
557
|
-
exports.buildGsubShaper = buildGsubShaper;
|
|
2
|
+
const require_gsub_table = require("./gsub-table-hFfYmf1W.cjs");
|
|
3
|
+
exports.DEFAULT_GSUB_FEATURE_TAGS = require_gsub_table.DEFAULT_GSUB_FEATURE_TAGS;
|
|
4
|
+
exports.EXTENSION_SUBST_HEADER_SIZE = require_gsub_table.EXTENSION_SUBST_HEADER_SIZE;
|
|
5
|
+
exports.EXTENSION_SUBST_OFFSET_FIELD_OFFSET = require_gsub_table.EXTENSION_SUBST_OFFSET_FIELD_OFFSET;
|
|
6
|
+
exports.GSUB_OPT_IN_FEATURE_TAGS = require_gsub_table.GSUB_OPT_IN_FEATURE_TAGS;
|
|
7
|
+
exports.LOOKUP_TYPE_CHAIN_CONTEXT_SUBST = require_gsub_table.LOOKUP_TYPE_CHAIN_CONTEXT_SUBST;
|
|
8
|
+
exports.LOOKUP_TYPE_CONTEXT_SUBST = require_gsub_table.LOOKUP_TYPE_CONTEXT_SUBST;
|
|
9
|
+
exports.LOOKUP_TYPE_EXTENSION_SUBST = require_gsub_table.LOOKUP_TYPE_EXTENSION_SUBST;
|
|
10
|
+
exports.LOOKUP_TYPE_LIGATURE_SUBST = require_gsub_table.LOOKUP_TYPE_LIGATURE_SUBST;
|
|
11
|
+
exports.LOOKUP_TYPE_SINGLE_SUBST = require_gsub_table.LOOKUP_TYPE_SINGLE_SUBST;
|
|
12
|
+
exports.MAX_LOOKUP_NESTING_DEPTH = require_gsub_table.MAX_LOOKUP_NESTING_DEPTH;
|
|
13
|
+
exports.SUBST_FORMAT_AND_COVERAGE_SIZE = require_gsub_table.SUBST_FORMAT_AND_COVERAGE_SIZE;
|
|
14
|
+
exports.buildGsubShaper = require_gsub_table.buildGsubShaper;
|
|
15
|
+
exports.constantZeroClassDef = require_gsub_table.constantZeroClassDef;
|
|
16
|
+
exports.glyphSkipper = require_gsub_table.glyphSkipper;
|
|
17
|
+
exports.nextVisibleSlot = require_gsub_table.nextVisibleSlot;
|
|
18
|
+
exports.parseLigatureSubstFormat1 = require_gsub_table.parseLigatureSubstFormat1;
|
|
19
|
+
exports.parseSingleSubstFormat1 = require_gsub_table.parseSingleSubstFormat1;
|
|
20
|
+
exports.parseSingleSubstFormat2 = require_gsub_table.parseSingleSubstFormat2;
|
|
21
|
+
exports.prevVisibleSlot = require_gsub_table.prevVisibleSlot;
|
|
22
|
+
exports.readTag = require_gsub_table.readTag;
|
package/dist/gsub-table.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { DEFAULT_GSUB_FEATURE_TAGS, GSUB_OPT_IN_FEATURE_TAGS, GsubOptInFeatureTag, GsubShaper, GsubShaperOptions, GsubShaping, buildGsubShaper };
|
|
1
|
+
import { A as readTag, C as constantZeroClassDef, D as parseSingleSubstFormat1, E as parseLigatureSubstFormat1, O as parseSingleSubstFormat2, S as buildGsubShaper, T as nextVisibleSlot, _ as MAX_LOOKUP_NESTING_DEPTH, a as GSUB_OPT_IN_FEATURE_TAGS, b as SlotApplication, c as GsubShaper, d as GsubSubtable, f as LOOKUP_TYPE_CHAIN_CONTEXT_SUBST, g as LOOKUP_TYPE_SINGLE_SUBST, h as LOOKUP_TYPE_LIGATURE_SUBST, i as EXTENSION_SUBST_OFFSET_FIELD_OFFSET, k as prevVisibleSlot, l as GsubShaperOptions, m as LOOKUP_TYPE_EXTENSION_SUBST, n as DEFAULT_GSUB_FEATURE_TAGS, o as GsubLookup, p as LOOKUP_TYPE_CONTEXT_SUBST, r as EXTENSION_SUBST_HEADER_SIZE, s as GsubOptInFeatureTag, t as ContextualGlyphTest, u as GsubShaping, v as SUBST_FORMAT_AND_COVERAGE_SIZE, w as glyphSkipper, x as SubstLookupRecord, y as ShapingSlot } from "./gsub-table-DW7Wmi9V.cjs";
|
|
2
|
+
export { ContextualGlyphTest, DEFAULT_GSUB_FEATURE_TAGS, EXTENSION_SUBST_HEADER_SIZE, EXTENSION_SUBST_OFFSET_FIELD_OFFSET, GSUB_OPT_IN_FEATURE_TAGS, GsubLookup, GsubOptInFeatureTag, GsubShaper, GsubShaperOptions, GsubShaping, GsubSubtable, LOOKUP_TYPE_CHAIN_CONTEXT_SUBST, LOOKUP_TYPE_CONTEXT_SUBST, LOOKUP_TYPE_EXTENSION_SUBST, LOOKUP_TYPE_LIGATURE_SUBST, LOOKUP_TYPE_SINGLE_SUBST, MAX_LOOKUP_NESTING_DEPTH, SUBST_FORMAT_AND_COVERAGE_SIZE, ShapingSlot, SlotApplication, SubstLookupRecord, buildGsubShaper, constantZeroClassDef, glyphSkipper, nextVisibleSlot, parseLigatureSubstFormat1, parseSingleSubstFormat1, parseSingleSubstFormat2, prevVisibleSlot, readTag };
|
package/dist/gsub-table.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { DEFAULT_GSUB_FEATURE_TAGS, GSUB_OPT_IN_FEATURE_TAGS, GsubOptInFeatureTag, GsubShaper, GsubShaperOptions, GsubShaping, buildGsubShaper };
|
|
1
|
+
import { A as readTag, C as constantZeroClassDef, D as parseSingleSubstFormat1, E as parseLigatureSubstFormat1, O as parseSingleSubstFormat2, S as buildGsubShaper, T as nextVisibleSlot, _ as MAX_LOOKUP_NESTING_DEPTH, a as GSUB_OPT_IN_FEATURE_TAGS, b as SlotApplication, c as GsubShaper, d as GsubSubtable, f as LOOKUP_TYPE_CHAIN_CONTEXT_SUBST, g as LOOKUP_TYPE_SINGLE_SUBST, h as LOOKUP_TYPE_LIGATURE_SUBST, i as EXTENSION_SUBST_OFFSET_FIELD_OFFSET, k as prevVisibleSlot, l as GsubShaperOptions, m as LOOKUP_TYPE_EXTENSION_SUBST, n as DEFAULT_GSUB_FEATURE_TAGS, o as GsubLookup, p as LOOKUP_TYPE_CONTEXT_SUBST, r as EXTENSION_SUBST_HEADER_SIZE, s as GsubOptInFeatureTag, t as ContextualGlyphTest, u as GsubShaping, v as SUBST_FORMAT_AND_COVERAGE_SIZE, w as glyphSkipper, x as SubstLookupRecord, y as ShapingSlot } from "./gsub-table-BDpJWqpf.js";
|
|
2
|
+
export { ContextualGlyphTest, DEFAULT_GSUB_FEATURE_TAGS, EXTENSION_SUBST_HEADER_SIZE, EXTENSION_SUBST_OFFSET_FIELD_OFFSET, GSUB_OPT_IN_FEATURE_TAGS, GsubLookup, GsubOptInFeatureTag, GsubShaper, GsubShaperOptions, GsubShaping, GsubSubtable, LOOKUP_TYPE_CHAIN_CONTEXT_SUBST, LOOKUP_TYPE_CONTEXT_SUBST, LOOKUP_TYPE_EXTENSION_SUBST, LOOKUP_TYPE_LIGATURE_SUBST, LOOKUP_TYPE_SINGLE_SUBST, MAX_LOOKUP_NESTING_DEPTH, SUBST_FORMAT_AND_COVERAGE_SIZE, ShapingSlot, SlotApplication, SubstLookupRecord, buildGsubShaper, constantZeroClassDef, glyphSkipper, nextVisibleSlot, parseLigatureSubstFormat1, parseSingleSubstFormat1, parseSingleSubstFormat2, prevVisibleSlot, readTag };
|