Leon4gr45 commited on
Commit
978a508
·
verified ·
1 Parent(s): c1adaf0

Include updated package-lock.json (part 21)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +11 -0
  2. node_modules/fontkit/src/layout/Script.js +231 -0
  3. node_modules/fontkit/src/layout/UnicodeLayoutEngine.js +250 -0
  4. node_modules/fontkit/src/node.js +17 -0
  5. node_modules/fontkit/src/opentype/GPOSProcessor.js +353 -0
  6. node_modules/fontkit/src/opentype/GSUBProcessor.js +192 -0
  7. node_modules/fontkit/src/opentype/GlyphInfo.js +57 -0
  8. node_modules/fontkit/src/opentype/GlyphIterator.js +70 -0
  9. node_modules/fontkit/src/opentype/OTLayoutEngine.js +113 -0
  10. node_modules/fontkit/src/opentype/OTProcessor.js +438 -0
  11. node_modules/fontkit/src/opentype/ShapingPlan.js +118 -0
  12. node_modules/fontkit/src/opentype/shapers/ArabicShaper.js +123 -0
  13. node_modules/fontkit/src/opentype/shapers/DefaultShaper.js +72 -0
  14. node_modules/fontkit/src/opentype/shapers/HangulShaper.js +285 -0
  15. node_modules/fontkit/src/opentype/shapers/IndicShaper.js +911 -0
  16. node_modules/fontkit/src/opentype/shapers/UniversalShaper.js +185 -0
  17. node_modules/fontkit/src/opentype/shapers/data.trie +0 -0
  18. node_modules/fontkit/src/opentype/shapers/gen-indic.js +208 -0
  19. node_modules/fontkit/src/opentype/shapers/gen-use.js +287 -0
  20. node_modules/fontkit/src/opentype/shapers/generate-data.js +33 -0
  21. node_modules/fontkit/src/opentype/shapers/index.js +102 -0
  22. node_modules/fontkit/src/opentype/shapers/indic-data.js +175 -0
  23. node_modules/fontkit/src/opentype/shapers/indic.json +1 -0
  24. node_modules/fontkit/src/opentype/shapers/indic.machine +31 -0
  25. node_modules/fontkit/src/opentype/shapers/indic.trie +0 -0
  26. node_modules/fontkit/src/opentype/shapers/use.json +1 -0
  27. node_modules/fontkit/src/opentype/shapers/use.machine +44 -0
  28. node_modules/fontkit/src/opentype/shapers/use.trie +0 -0
  29. node_modules/fontkit/src/subset/CFFSubset.js +171 -0
  30. node_modules/fontkit/src/subset/Subset.js +27 -0
  31. node_modules/fontkit/src/subset/TTFSubset.js +131 -0
  32. node_modules/fontkit/src/tables/BASE.js +78 -0
  33. node_modules/fontkit/src/tables/COLR.js +25 -0
  34. node_modules/fontkit/src/tables/CPAL.js +24 -0
  35. node_modules/fontkit/src/tables/DSIG.js +21 -0
  36. node_modules/fontkit/src/tables/EBDT.js +91 -0
  37. node_modules/fontkit/src/tables/EBLC.js +80 -0
  38. node_modules/fontkit/src/tables/GDEF.js +57 -0
  39. node_modules/fontkit/src/tables/GPOS.js +209 -0
  40. node_modules/fontkit/src/tables/GSUB.js +84 -0
  41. node_modules/fontkit/src/tables/HVAR.js +44 -0
  42. node_modules/fontkit/src/tables/JSTF.js +43 -0
  43. node_modules/fontkit/src/tables/LTSH.js +10 -0
  44. node_modules/fontkit/src/tables/OS2.js +84 -0
  45. node_modules/fontkit/src/tables/PCLT.js +21 -0
  46. node_modules/fontkit/src/tables/VDMX.js +33 -0
  47. node_modules/fontkit/src/tables/VORG.js +14 -0
  48. node_modules/fontkit/src/tables/WOFF2Directory.js +74 -0
  49. node_modules/fontkit/src/tables/WOFFDirectory.js +38 -0
  50. node_modules/fontkit/src/tables/aat.js +157 -0
.gitattributes CHANGED
@@ -62,3 +62,14 @@ node_modules/bare-url/prebuilds/win32-x64/bare-url.bare filter=lfs diff=lfs merg
62
  node_modules/better-sqlite3/build/Release/better_sqlite3.node filter=lfs diff=lfs merge=lfs -text
63
  node_modules/concurrently/docs/demo.gif filter=lfs diff=lfs merge=lfs -text
64
  node_modules/exif-parser/test/starfish.jpg filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
62
  node_modules/better-sqlite3/build/Release/better_sqlite3.node filter=lfs diff=lfs merge=lfs -text
63
  node_modules/concurrently/docs/demo.gif filter=lfs diff=lfs merge=lfs -text
64
  node_modules/exif-parser/test/starfish.jpg filter=lfs diff=lfs merge=lfs -text
65
+ node_modules/gifwrap/test/fixtures/hairstreak.jpg filter=lfs diff=lfs merge=lfs -text
66
+ node_modules/gifwrap/test/fixtures/lenna.png filter=lfs diff=lfs merge=lfs -text
67
+ node_modules/gifwrap/test/fixtures/nburling-public.gif filter=lfs diff=lfs merge=lfs -text
68
+ node_modules/gifwrap/test/fixtures/quantized/hairstreak256_Dekker.png filter=lfs diff=lfs merge=lfs -text
69
+ node_modules/gifwrap/test/fixtures/quantized/hairstreak256_Sorokin.png filter=lfs diff=lfs merge=lfs -text
70
+ node_modules/gifwrap/test/fixtures/quantized/hairstreak256_Wu.png filter=lfs diff=lfs merge=lfs -text
71
+ node_modules/gifwrap/test/fixtures/quantized/hairstreak32_Dekker.png filter=lfs diff=lfs merge=lfs -text
72
+ node_modules/gifwrap/test/fixtures/quantized/hairstreak32_Sorokin.png filter=lfs diff=lfs merge=lfs -text
73
+ node_modules/gifwrap/test/fixtures/quantized/hairstreak32_Wu.png filter=lfs diff=lfs merge=lfs -text
74
+ node_modules/gifwrap/test/fixtures/quantized/sculptmap256_Sorokin_FloydSteinberg.png filter=lfs diff=lfs merge=lfs -text
75
+ node_modules/gifwrap/test/fixtures/rnaples-offsets-public.gif filter=lfs diff=lfs merge=lfs -text
node_modules/fontkit/src/layout/Script.js ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {getScript} from 'unicode-properties';
2
+
3
+ // This maps the Unicode Script property to an OpenType script tag
4
+ // Data from http://www.microsoft.com/typography/otspec/scripttags.htm
5
+ // and http://www.unicode.org/Public/UNIDATA/PropertyValueAliases.txt.
6
+ const UNICODE_SCRIPTS = {
7
+ Caucasian_Albanian: 'aghb',
8
+ Arabic: 'arab',
9
+ Imperial_Aramaic: 'armi',
10
+ Armenian: 'armn',
11
+ Avestan: 'avst',
12
+ Balinese: 'bali',
13
+ Bamum: 'bamu',
14
+ Bassa_Vah: 'bass',
15
+ Batak: 'batk',
16
+ Bengali: ['bng2', 'beng'],
17
+ Bopomofo: 'bopo',
18
+ Brahmi: 'brah',
19
+ Braille: 'brai',
20
+ Buginese: 'bugi',
21
+ Buhid: 'buhd',
22
+ Chakma: 'cakm',
23
+ Canadian_Aboriginal: 'cans',
24
+ Carian: 'cari',
25
+ Cham: 'cham',
26
+ Cherokee: 'cher',
27
+ Coptic: 'copt',
28
+ Cypriot: 'cprt',
29
+ Cyrillic: 'cyrl',
30
+ Devanagari: ['dev2', 'deva'],
31
+ Deseret: 'dsrt',
32
+ Duployan: 'dupl',
33
+ Egyptian_Hieroglyphs: 'egyp',
34
+ Elbasan: 'elba',
35
+ Ethiopic: 'ethi',
36
+ Georgian: 'geor',
37
+ Glagolitic: 'glag',
38
+ Gothic: 'goth',
39
+ Grantha: 'gran',
40
+ Greek: 'grek',
41
+ Gujarati: ['gjr2', 'gujr'],
42
+ Gurmukhi: ['gur2', 'guru'],
43
+ Hangul: 'hang',
44
+ Han: 'hani',
45
+ Hanunoo: 'hano',
46
+ Hebrew: 'hebr',
47
+ Hiragana: 'hira',
48
+ Pahawh_Hmong: 'hmng',
49
+ Katakana_Or_Hiragana: 'hrkt',
50
+ Old_Italic: 'ital',
51
+ Javanese: 'java',
52
+ Kayah_Li: 'kali',
53
+ Katakana: 'kana',
54
+ Kharoshthi: 'khar',
55
+ Khmer: 'khmr',
56
+ Khojki: 'khoj',
57
+ Kannada: ['knd2', 'knda'],
58
+ Kaithi: 'kthi',
59
+ Tai_Tham: 'lana',
60
+ Lao: 'lao ',
61
+ Latin: 'latn',
62
+ Lepcha: 'lepc',
63
+ Limbu: 'limb',
64
+ Linear_A: 'lina',
65
+ Linear_B: 'linb',
66
+ Lisu: 'lisu',
67
+ Lycian: 'lyci',
68
+ Lydian: 'lydi',
69
+ Mahajani: 'mahj',
70
+ Mandaic: 'mand',
71
+ Manichaean: 'mani',
72
+ Mende_Kikakui: 'mend',
73
+ Meroitic_Cursive: 'merc',
74
+ Meroitic_Hieroglyphs: 'mero',
75
+ Malayalam: ['mlm2', 'mlym'],
76
+ Modi: 'modi',
77
+ Mongolian: 'mong',
78
+ Mro: 'mroo',
79
+ Meetei_Mayek: 'mtei',
80
+ Myanmar: ['mym2', 'mymr'],
81
+ Old_North_Arabian: 'narb',
82
+ Nabataean: 'nbat',
83
+ Nko: 'nko ',
84
+ Ogham: 'ogam',
85
+ Ol_Chiki: 'olck',
86
+ Old_Turkic: 'orkh',
87
+ Oriya: ['ory2', 'orya'],
88
+ Osmanya: 'osma',
89
+ Palmyrene: 'palm',
90
+ Pau_Cin_Hau: 'pauc',
91
+ Old_Permic: 'perm',
92
+ Phags_Pa: 'phag',
93
+ Inscriptional_Pahlavi: 'phli',
94
+ Psalter_Pahlavi: 'phlp',
95
+ Phoenician: 'phnx',
96
+ Miao: 'plrd',
97
+ Inscriptional_Parthian: 'prti',
98
+ Rejang: 'rjng',
99
+ Runic: 'runr',
100
+ Samaritan: 'samr',
101
+ Old_South_Arabian: 'sarb',
102
+ Saurashtra: 'saur',
103
+ Shavian: 'shaw',
104
+ Sharada: 'shrd',
105
+ Siddham: 'sidd',
106
+ Khudawadi: 'sind',
107
+ Sinhala: 'sinh',
108
+ Sora_Sompeng: 'sora',
109
+ Sundanese: 'sund',
110
+ Syloti_Nagri: 'sylo',
111
+ Syriac: 'syrc',
112
+ Tagbanwa: 'tagb',
113
+ Takri: 'takr',
114
+ Tai_Le: 'tale',
115
+ New_Tai_Lue: 'talu',
116
+ Tamil: ['tml2', 'taml'],
117
+ Tai_Viet: 'tavt',
118
+ Telugu: ['tel2', 'telu'],
119
+ Tifinagh: 'tfng',
120
+ Tagalog: 'tglg',
121
+ Thaana: 'thaa',
122
+ Thai: 'thai',
123
+ Tibetan: 'tibt',
124
+ Tirhuta: 'tirh',
125
+ Ugaritic: 'ugar',
126
+ Vai: 'vai ',
127
+ Warang_Citi: 'wara',
128
+ Old_Persian: 'xpeo',
129
+ Cuneiform: 'xsux',
130
+ Yi: 'yi ',
131
+ Inherited: 'zinh',
132
+ Common: 'zyyy',
133
+ Unknown: 'zzzz'
134
+ };
135
+
136
+ const OPENTYPE_SCRIPTS = {};
137
+ for (let script in UNICODE_SCRIPTS) {
138
+ let tag = UNICODE_SCRIPTS[script];
139
+ if (Array.isArray(tag)) {
140
+ for (let t of tag) {
141
+ OPENTYPE_SCRIPTS[t] = script;
142
+ }
143
+ } else {
144
+ OPENTYPE_SCRIPTS[tag] = script;
145
+ }
146
+ }
147
+
148
+ export function fromUnicode(script) {
149
+ return UNICODE_SCRIPTS[script];
150
+ }
151
+
152
+ export function fromOpenType(tag) {
153
+ return OPENTYPE_SCRIPTS[tag];
154
+ }
155
+
156
+ export function forString(string) {
157
+ let len = string.length;
158
+ let idx = 0;
159
+ while (idx < len) {
160
+ let code = string.charCodeAt(idx++);
161
+
162
+ // Check if this is a high surrogate
163
+ if (0xd800 <= code && code <= 0xdbff && idx < len) {
164
+ let next = string.charCodeAt(idx);
165
+
166
+ // Check if this is a low surrogate
167
+ if (0xdc00 <= next && next <= 0xdfff) {
168
+ idx++;
169
+ code = ((code & 0x3FF) << 10) + (next & 0x3FF) + 0x10000;
170
+ }
171
+ }
172
+
173
+ let script = getScript(code);
174
+ if (script !== 'Common' && script !== 'Inherited' && script !== 'Unknown') {
175
+ return UNICODE_SCRIPTS[script];
176
+ }
177
+ }
178
+
179
+ return UNICODE_SCRIPTS.Unknown;
180
+ }
181
+
182
+ export function forCodePoints(codePoints) {
183
+ for (let i = 0; i < codePoints.length; i++) {
184
+ let codePoint = codePoints[i];
185
+ let script = getScript(codePoint);
186
+ if (script !== 'Common' && script !== 'Inherited' && script !== 'Unknown') {
187
+ return UNICODE_SCRIPTS[script];
188
+ }
189
+ }
190
+
191
+ return UNICODE_SCRIPTS.Unknown;
192
+ }
193
+
194
+ // The scripts in this map are written from right to left
195
+ const RTL = {
196
+ arab: true, // Arabic
197
+ hebr: true, // Hebrew
198
+ syrc: true, // Syriac
199
+ thaa: true, // Thaana
200
+ cprt: true, // Cypriot Syllabary
201
+ khar: true, // Kharosthi
202
+ phnx: true, // Phoenician
203
+ 'nko ': true, // N'Ko
204
+ lydi: true, // Lydian
205
+ avst: true, // Avestan
206
+ armi: true, // Imperial Aramaic
207
+ phli: true, // Inscriptional Pahlavi
208
+ prti: true, // Inscriptional Parthian
209
+ sarb: true, // Old South Arabian
210
+ orkh: true, // Old Turkic, Orkhon Runic
211
+ samr: true, // Samaritan
212
+ mand: true, // Mandaic, Mandaean
213
+ merc: true, // Meroitic Cursive
214
+ mero: true, // Meroitic Hieroglyphs
215
+
216
+ // Unicode 7.0 (not listed on http://www.microsoft.com/typography/otspec/scripttags.htm)
217
+ mani: true, // Manichaean
218
+ mend: true, // Mende Kikakui
219
+ nbat: true, // Nabataean
220
+ narb: true, // Old North Arabian
221
+ palm: true, // Palmyrene
222
+ phlp: true // Psalter Pahlavi
223
+ };
224
+
225
+ export function direction(script) {
226
+ if (RTL[script]) {
227
+ return 'rtl';
228
+ }
229
+
230
+ return 'ltr';
231
+ }
node_modules/fontkit/src/layout/UnicodeLayoutEngine.js ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {getCombiningClass} from 'unicode-properties';
2
+
3
+ /**
4
+ * This class is used when GPOS does not define 'mark' or 'mkmk' features
5
+ * for positioning marks relative to base glyphs. It uses the unicode
6
+ * combining class property to position marks.
7
+ *
8
+ * Based on code from Harfbuzz, thanks!
9
+ * https://github.com/behdad/harfbuzz/blob/master/src/hb-ot-shape-fallback.cc
10
+ */
11
+ export default class UnicodeLayoutEngine {
12
+ constructor(font) {
13
+ this.font = font;
14
+ }
15
+
16
+ positionGlyphs(glyphs, positions) {
17
+ // find each base + mark cluster, and position the marks relative to the base
18
+ let clusterStart = 0;
19
+ let clusterEnd = 0;
20
+ for (let index = 0; index < glyphs.length; index++) {
21
+ let glyph = glyphs[index];
22
+ if (glyph.isMark) { // TODO: handle ligatures
23
+ clusterEnd = index;
24
+ } else {
25
+ if (clusterStart !== clusterEnd) {
26
+ this.positionCluster(glyphs, positions, clusterStart, clusterEnd);
27
+ }
28
+
29
+ clusterStart = clusterEnd = index;
30
+ }
31
+ }
32
+
33
+ if (clusterStart !== clusterEnd) {
34
+ this.positionCluster(glyphs, positions, clusterStart, clusterEnd);
35
+ }
36
+
37
+ return positions;
38
+ }
39
+
40
+ positionCluster(glyphs, positions, clusterStart, clusterEnd) {
41
+ let base = glyphs[clusterStart];
42
+ let baseBox = base.cbox.copy();
43
+
44
+ // adjust bounding box for ligature glyphs
45
+ if (base.codePoints.length > 1) {
46
+ // LTR. TODO: RTL support.
47
+ baseBox.minX += ((base.codePoints.length - 1) * baseBox.width) / base.codePoints.length;
48
+ }
49
+
50
+ let xOffset = -positions[clusterStart].xAdvance;
51
+ let yOffset = 0;
52
+ let yGap = this.font.unitsPerEm / 16;
53
+
54
+ // position each of the mark glyphs relative to the base glyph
55
+ for (let index = clusterStart + 1; index <= clusterEnd; index++) {
56
+ let mark = glyphs[index];
57
+ let markBox = mark.cbox;
58
+ let position = positions[index];
59
+
60
+ let combiningClass = this.getCombiningClass(mark.codePoints[0]);
61
+
62
+ if (combiningClass !== 'Not_Reordered') {
63
+ position.xOffset = position.yOffset = 0;
64
+
65
+ // x positioning
66
+ switch (combiningClass) {
67
+ case 'Double_Above':
68
+ case 'Double_Below':
69
+ // LTR. TODO: RTL support.
70
+ position.xOffset += baseBox.minX - markBox.width / 2 - markBox.minX;
71
+ break;
72
+
73
+ case 'Attached_Below_Left':
74
+ case 'Below_Left':
75
+ case 'Above_Left':
76
+ // left align
77
+ position.xOffset += baseBox.minX - markBox.minX;
78
+ break;
79
+
80
+ case 'Attached_Above_Right':
81
+ case 'Below_Right':
82
+ case 'Above_Right':
83
+ // right align
84
+ position.xOffset += baseBox.maxX - markBox.width - markBox.minX;
85
+ break;
86
+
87
+ default: // Attached_Below, Attached_Above, Below, Above, other
88
+ // center align
89
+ position.xOffset += baseBox.minX + (baseBox.width - markBox.width) / 2 - markBox.minX;
90
+ }
91
+
92
+ // y positioning
93
+ switch (combiningClass) {
94
+ case 'Double_Below':
95
+ case 'Below_Left':
96
+ case 'Below':
97
+ case 'Below_Right':
98
+ case 'Attached_Below_Left':
99
+ case 'Attached_Below':
100
+ // add a small gap between the glyphs if they are not attached
101
+ if (combiningClass === 'Attached_Below_Left' || combiningClass === 'Attached_Below') {
102
+ baseBox.minY += yGap;
103
+ }
104
+
105
+ position.yOffset = -baseBox.minY - markBox.maxY;
106
+ baseBox.minY += markBox.height;
107
+ break;
108
+
109
+ case 'Double_Above':
110
+ case 'Above_Left':
111
+ case 'Above':
112
+ case 'Above_Right':
113
+ case 'Attached_Above':
114
+ case 'Attached_Above_Right':
115
+ // add a small gap between the glyphs if they are not attached
116
+ if (combiningClass === 'Attached_Above' || combiningClass === 'Attached_Above_Right') {
117
+ baseBox.maxY += yGap;
118
+ }
119
+
120
+ position.yOffset = baseBox.maxY - markBox.minY;
121
+ baseBox.maxY += markBox.height;
122
+ break;
123
+ }
124
+
125
+ position.xAdvance = position.yAdvance = 0;
126
+ position.xOffset += xOffset;
127
+ position.yOffset += yOffset;
128
+
129
+ } else {
130
+ xOffset -= position.xAdvance;
131
+ yOffset -= position.yAdvance;
132
+ }
133
+ }
134
+
135
+ return;
136
+ }
137
+
138
+ getCombiningClass(codePoint) {
139
+ let combiningClass = getCombiningClass(codePoint);
140
+
141
+ // Thai / Lao need some per-character work
142
+ if ((codePoint & ~0xff) === 0x0e00) {
143
+ if (combiningClass === 'Not_Reordered') {
144
+ switch (codePoint) {
145
+ case 0x0e31:
146
+ case 0x0e34:
147
+ case 0x0e35:
148
+ case 0x0e36:
149
+ case 0x0e37:
150
+ case 0x0e47:
151
+ case 0x0e4c:
152
+ case 0x0e3d:
153
+ case 0x0e4e:
154
+ return 'Above_Right';
155
+
156
+ case 0x0eb1:
157
+ case 0x0eb4:
158
+ case 0x0eb5:
159
+ case 0x0eb6:
160
+ case 0x0eb7:
161
+ case 0x0ebb:
162
+ case 0x0ecc:
163
+ case 0x0ecd:
164
+ return 'Above';
165
+
166
+ case 0x0ebc:
167
+ return 'Below';
168
+ }
169
+ } else if (codePoint === 0x0e3a) { // virama
170
+ return 'Below_Right';
171
+ }
172
+ }
173
+
174
+ switch (combiningClass) {
175
+ // Hebrew
176
+
177
+ case 'CCC10': // sheva
178
+ case 'CCC11': // hataf segol
179
+ case 'CCC12': // hataf patah
180
+ case 'CCC13': // hataf qamats
181
+ case 'CCC14': // hiriq
182
+ case 'CCC15': // tsere
183
+ case 'CCC16': // segol
184
+ case 'CCC17': // patah
185
+ case 'CCC18': // qamats
186
+ case 'CCC20': // qubuts
187
+ case 'CCC22': // meteg
188
+ return 'Below';
189
+
190
+ case 'CCC23': // rafe
191
+ return 'Attached_Above';
192
+
193
+ case 'CCC24': // shin dot
194
+ return 'Above_Right';
195
+
196
+ case 'CCC25': // sin dot
197
+ case 'CCC19': // holam
198
+ return 'Above_Left';
199
+
200
+ case 'CCC26': // point varika
201
+ return 'Above';
202
+
203
+ case 'CCC21': // dagesh
204
+ break;
205
+
206
+ // Arabic and Syriac
207
+
208
+ case 'CCC27': // fathatan
209
+ case 'CCC28': // dammatan
210
+ case 'CCC30': // fatha
211
+ case 'CCC31': // damma
212
+ case 'CCC33': // shadda
213
+ case 'CCC34': // sukun
214
+ case 'CCC35': // superscript alef
215
+ case 'CCC36': // superscript alaph
216
+ return 'Above';
217
+
218
+ case 'CCC29': // kasratan
219
+ case 'CCC32': // kasra
220
+ return 'Below';
221
+
222
+ // Thai
223
+
224
+ case 'CCC103': // sara u / sara uu
225
+ return 'Below_Right';
226
+
227
+ case 'CCC107': // mai
228
+ return 'Above_Right';
229
+
230
+ // Lao
231
+
232
+ case 'CCC118': // sign u / sign uu
233
+ return 'Below';
234
+
235
+ case 'CCC122': // mai
236
+ return 'Above';
237
+
238
+ // Tibetan
239
+
240
+ case 'CCC129': // sign aa
241
+ case 'CCC132': // sign u
242
+ return 'Below';
243
+
244
+ case 'CCC130': // sign i
245
+ return 'Above';
246
+ }
247
+
248
+ return combiningClass;
249
+ }
250
+ }
node_modules/fontkit/src/node.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { registerFormat, create, defaultLanguage, setDefaultLanguage } from './base';
2
+ import { open, openSync } from './fs';
3
+ import TTFFont from './TTFFont';
4
+ import WOFFFont from './WOFFFont';
5
+ import WOFF2Font from './WOFF2Font';
6
+ import TrueTypeCollection from './TrueTypeCollection';
7
+ import DFont from './DFont';
8
+
9
+ // Register font formats
10
+ registerFormat(TTFFont);
11
+ registerFormat(WOFFFont);
12
+ registerFormat(WOFF2Font);
13
+ registerFormat(TrueTypeCollection);
14
+ registerFormat(DFont);
15
+
16
+ export * from './base';
17
+ export * from './fs';
node_modules/fontkit/src/opentype/GPOSProcessor.js ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OTProcessor from './OTProcessor';
2
+
3
+ export default class GPOSProcessor extends OTProcessor {
4
+ applyPositionValue(sequenceIndex, value) {
5
+ let position = this.positions[this.glyphIterator.peekIndex(sequenceIndex)];
6
+ if (value.xAdvance != null) {
7
+ position.xAdvance += value.xAdvance;
8
+ }
9
+
10
+ if (value.yAdvance != null) {
11
+ position.yAdvance += value.yAdvance;
12
+ }
13
+
14
+ if (value.xPlacement != null) {
15
+ position.xOffset += value.xPlacement;
16
+ }
17
+
18
+ if (value.yPlacement != null) {
19
+ position.yOffset += value.yPlacement;
20
+ }
21
+
22
+ // Adjustments for font variations
23
+ let variationProcessor = this.font._variationProcessor;
24
+ let variationStore = this.font.GDEF && this.font.GDEF.itemVariationStore;
25
+ if (variationProcessor && variationStore) {
26
+ if (value.xPlaDevice) {
27
+ position.xOffset += variationProcessor.getDelta(variationStore, value.xPlaDevice.a, value.xPlaDevice.b);
28
+ }
29
+
30
+ if (value.yPlaDevice) {
31
+ position.yOffset += variationProcessor.getDelta(variationStore, value.yPlaDevice.a, value.yPlaDevice.b);
32
+ }
33
+
34
+ if (value.xAdvDevice) {
35
+ position.xAdvance += variationProcessor.getDelta(variationStore, value.xAdvDevice.a, value.xAdvDevice.b);
36
+ }
37
+
38
+ if (value.yAdvDevice) {
39
+ position.yAdvance += variationProcessor.getDelta(variationStore, value.yAdvDevice.a, value.yAdvDevice.b);
40
+ }
41
+ }
42
+
43
+ // TODO: device tables
44
+ }
45
+
46
+ applyLookup(lookupType, table) {
47
+ switch (lookupType) {
48
+ case 1: { // Single positioning value
49
+ let index = this.coverageIndex(table.coverage);
50
+ if (index === -1) {
51
+ return false;
52
+ }
53
+
54
+ switch (table.version) {
55
+ case 1:
56
+ this.applyPositionValue(0, table.value);
57
+ break;
58
+
59
+ case 2:
60
+ this.applyPositionValue(0, table.values.get(index));
61
+ break;
62
+ }
63
+
64
+ return true;
65
+ }
66
+
67
+ case 2: { // Pair Adjustment Positioning
68
+ let nextGlyph = this.glyphIterator.peek();
69
+ if (!nextGlyph) {
70
+ return false;
71
+ }
72
+
73
+ let index = this.coverageIndex(table.coverage);
74
+ if (index === -1) {
75
+ return false;
76
+ }
77
+
78
+ switch (table.version) {
79
+ case 1: // Adjustments for glyph pairs
80
+ let set = table.pairSets.get(index);
81
+
82
+ for (let pair of set) {
83
+ if (pair.secondGlyph === nextGlyph.id) {
84
+ this.applyPositionValue(0, pair.value1);
85
+ this.applyPositionValue(1, pair.value2);
86
+ return true;
87
+ }
88
+ }
89
+
90
+ return false;
91
+
92
+ case 2: // Class pair adjustment
93
+ let class1 = this.getClassID(this.glyphIterator.cur.id, table.classDef1);
94
+ let class2 = this.getClassID(nextGlyph.id, table.classDef2);
95
+ if (class1 === -1 || class2 === -1) {
96
+ return false;
97
+ }
98
+
99
+ var pair = table.classRecords.get(class1).get(class2);
100
+ this.applyPositionValue(0, pair.value1);
101
+ this.applyPositionValue(1, pair.value2);
102
+ return true;
103
+ }
104
+ }
105
+
106
+ case 3: { // Cursive Attachment Positioning
107
+ let nextIndex = this.glyphIterator.peekIndex();
108
+ let nextGlyph = this.glyphs[nextIndex];
109
+ if (!nextGlyph) {
110
+ return false;
111
+ }
112
+
113
+ let curRecord = table.entryExitRecords[this.coverageIndex(table.coverage)];
114
+ if (!curRecord || !curRecord.exitAnchor) {
115
+ return false;
116
+ }
117
+
118
+ let nextRecord = table.entryExitRecords[this.coverageIndex(table.coverage, nextGlyph.id)];
119
+ if (!nextRecord || !nextRecord.entryAnchor) {
120
+ return false;
121
+ }
122
+
123
+ let entry = this.getAnchor(nextRecord.entryAnchor);
124
+ let exit = this.getAnchor(curRecord.exitAnchor);
125
+
126
+ let cur = this.positions[this.glyphIterator.index];
127
+ let next = this.positions[nextIndex];
128
+ let d;
129
+
130
+ switch (this.direction) {
131
+ case 'ltr':
132
+ cur.xAdvance = exit.x + cur.xOffset;
133
+
134
+ d = entry.x + next.xOffset;
135
+ next.xAdvance -= d;
136
+ next.xOffset -= d;
137
+ break;
138
+
139
+ case 'rtl':
140
+ d = exit.x + cur.xOffset;
141
+ cur.xAdvance -= d;
142
+ cur.xOffset -= d;
143
+ next.xAdvance = entry.x + next.xOffset;
144
+ break;
145
+ }
146
+
147
+ if (this.glyphIterator.flags.rightToLeft) {
148
+ this.glyphIterator.cur.cursiveAttachment = nextIndex;
149
+ cur.yOffset = entry.y - exit.y;
150
+ } else {
151
+ nextGlyph.cursiveAttachment = this.glyphIterator.index;
152
+ cur.yOffset = exit.y - entry.y;
153
+ }
154
+
155
+ return true;
156
+ }
157
+
158
+ case 4: { // Mark to base positioning
159
+ let markIndex = this.coverageIndex(table.markCoverage);
160
+ if (markIndex === -1) {
161
+ return false;
162
+ }
163
+
164
+ // search backward for a base glyph
165
+ let baseGlyphIndex = this.glyphIterator.index;
166
+ while (--baseGlyphIndex >= 0 && (this.glyphs[baseGlyphIndex].isMark || this.glyphs[baseGlyphIndex].ligatureComponent > 0));
167
+
168
+ if (baseGlyphIndex < 0) {
169
+ return false;
170
+ }
171
+
172
+ let baseIndex = this.coverageIndex(table.baseCoverage, this.glyphs[baseGlyphIndex].id);
173
+ if (baseIndex === -1) {
174
+ return false;
175
+ }
176
+
177
+ let markRecord = table.markArray[markIndex];
178
+ let baseAnchor = table.baseArray[baseIndex][markRecord.class];
179
+ this.applyAnchor(markRecord, baseAnchor, baseGlyphIndex);
180
+ return true;
181
+ }
182
+
183
+ case 5: { // Mark to ligature positioning
184
+ let markIndex = this.coverageIndex(table.markCoverage);
185
+ if (markIndex === -1) {
186
+ return false;
187
+ }
188
+
189
+ // search backward for a base glyph
190
+ let baseGlyphIndex = this.glyphIterator.index;
191
+ while (--baseGlyphIndex >= 0 && this.glyphs[baseGlyphIndex].isMark);
192
+
193
+ if (baseGlyphIndex < 0) {
194
+ return false;
195
+ }
196
+
197
+ let ligIndex = this.coverageIndex(table.ligatureCoverage, this.glyphs[baseGlyphIndex].id);
198
+ if (ligIndex === -1) {
199
+ return false;
200
+ }
201
+
202
+ let ligAttach = table.ligatureArray[ligIndex];
203
+ let markGlyph = this.glyphIterator.cur;
204
+ let ligGlyph = this.glyphs[baseGlyphIndex];
205
+ let compIndex = ligGlyph.ligatureID && ligGlyph.ligatureID === markGlyph.ligatureID && (markGlyph.ligatureComponent > 0)
206
+ ? Math.min(markGlyph.ligatureComponent, ligGlyph.codePoints.length) - 1
207
+ : ligGlyph.codePoints.length - 1;
208
+
209
+ let markRecord = table.markArray[markIndex];
210
+ let baseAnchor = ligAttach[compIndex][markRecord.class];
211
+ this.applyAnchor(markRecord, baseAnchor, baseGlyphIndex);
212
+ return true;
213
+ }
214
+
215
+ case 6: { // Mark to mark positioning
216
+ let mark1Index = this.coverageIndex(table.mark1Coverage);
217
+ if (mark1Index === -1) {
218
+ return false;
219
+ }
220
+
221
+ // get the previous mark to attach to
222
+ let prevIndex = this.glyphIterator.peekIndex(-1);
223
+ let prev = this.glyphs[prevIndex];
224
+ if (!prev || !prev.isMark) {
225
+ return false;
226
+ }
227
+
228
+ let cur = this.glyphIterator.cur;
229
+
230
+ // The following logic was borrowed from Harfbuzz
231
+ let good = false;
232
+ if (cur.ligatureID === prev.ligatureID) {
233
+ if (!cur.ligatureID) { // Marks belonging to the same base
234
+ good = true;
235
+ } else if (cur.ligatureComponent === prev.ligatureComponent) { // Marks belonging to the same ligature component
236
+ good = true;
237
+ }
238
+ } else {
239
+ // If ligature ids don't match, it may be the case that one of the marks
240
+ // itself is a ligature, in which case match.
241
+ if ((cur.ligatureID && !cur.ligatureComponent) || (prev.ligatureID && !prev.ligatureComponent)) {
242
+ good = true;
243
+ }
244
+ }
245
+
246
+ if (!good) {
247
+ return false;
248
+ }
249
+
250
+ let mark2Index = this.coverageIndex(table.mark2Coverage, prev.id);
251
+ if (mark2Index === -1) {
252
+ return false;
253
+ }
254
+
255
+ let markRecord = table.mark1Array[mark1Index];
256
+ let baseAnchor = table.mark2Array[mark2Index][markRecord.class];
257
+ this.applyAnchor(markRecord, baseAnchor, prevIndex);
258
+ return true;
259
+ }
260
+
261
+ case 7: // Contextual positioning
262
+ return this.applyContext(table);
263
+
264
+ case 8: // Chaining contextual positioning
265
+ return this.applyChainingContext(table);
266
+
267
+ case 9: // Extension positioning
268
+ return this.applyLookup(table.lookupType, table.extension);
269
+
270
+ default:
271
+ throw new Error(`Unsupported GPOS table: ${lookupType}`);
272
+ }
273
+ }
274
+
275
+ applyAnchor(markRecord, baseAnchor, baseGlyphIndex) {
276
+ let baseCoords = this.getAnchor(baseAnchor);
277
+ let markCoords = this.getAnchor(markRecord.markAnchor);
278
+
279
+ let basePos = this.positions[baseGlyphIndex];
280
+ let markPos = this.positions[this.glyphIterator.index];
281
+
282
+ markPos.xOffset = baseCoords.x - markCoords.x;
283
+ markPos.yOffset = baseCoords.y - markCoords.y;
284
+ this.glyphIterator.cur.markAttachment = baseGlyphIndex;
285
+ }
286
+
287
+ getAnchor(anchor) {
288
+ // TODO: contour point, device tables
289
+ let x = anchor.xCoordinate;
290
+ let y = anchor.yCoordinate;
291
+
292
+ // Adjustments for font variations
293
+ let variationProcessor = this.font._variationProcessor;
294
+ let variationStore = this.font.GDEF && this.font.GDEF.itemVariationStore;
295
+ if (variationProcessor && variationStore) {
296
+ if (anchor.xDeviceTable) {
297
+ x += variationProcessor.getDelta(variationStore, anchor.xDeviceTable.a, anchor.xDeviceTable.b);
298
+ }
299
+
300
+ if (anchor.yDeviceTable) {
301
+ y += variationProcessor.getDelta(variationStore, anchor.yDeviceTable.a, anchor.yDeviceTable.b);
302
+ }
303
+ }
304
+
305
+ return { x, y };
306
+ }
307
+
308
+ applyFeatures(userFeatures, glyphs, advances) {
309
+ super.applyFeatures(userFeatures, glyphs, advances);
310
+
311
+ for (var i = 0; i < this.glyphs.length; i++) {
312
+ this.fixCursiveAttachment(i);
313
+ }
314
+
315
+ this.fixMarkAttachment();
316
+ }
317
+
318
+ fixCursiveAttachment(i) {
319
+ let glyph = this.glyphs[i];
320
+ if (glyph.cursiveAttachment != null) {
321
+ let j = glyph.cursiveAttachment;
322
+
323
+ glyph.cursiveAttachment = null;
324
+ this.fixCursiveAttachment(j);
325
+
326
+ this.positions[i].yOffset += this.positions[j].yOffset;
327
+ }
328
+ }
329
+
330
+ fixMarkAttachment() {
331
+ for (let i = 0; i < this.glyphs.length; i++) {
332
+ let glyph = this.glyphs[i];
333
+ if (glyph.markAttachment != null) {
334
+ let j = glyph.markAttachment;
335
+
336
+ this.positions[i].xOffset += this.positions[j].xOffset;
337
+ this.positions[i].yOffset += this.positions[j].yOffset;
338
+
339
+ if (this.direction === 'ltr') {
340
+ for (let k = j; k < i; k++) {
341
+ this.positions[i].xOffset -= this.positions[k].xAdvance;
342
+ this.positions[i].yOffset -= this.positions[k].yAdvance;
343
+ }
344
+ } else {
345
+ for (let k = j + 1; k < i + 1; k++) {
346
+ this.positions[i].xOffset += this.positions[k].xAdvance;
347
+ this.positions[i].yOffset += this.positions[k].yAdvance;
348
+ }
349
+ }
350
+ }
351
+ }
352
+ }
353
+ }
node_modules/fontkit/src/opentype/GSUBProcessor.js ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import OTProcessor from './OTProcessor';
2
+ import GlyphInfo from './GlyphInfo';
3
+
4
+ export default class GSUBProcessor extends OTProcessor {
5
+ applyLookup(lookupType, table) {
6
+ switch (lookupType) {
7
+ case 1: { // Single Substitution
8
+ let index = this.coverageIndex(table.coverage);
9
+ if (index === -1) {
10
+ return false;
11
+ }
12
+
13
+ let glyph = this.glyphIterator.cur;
14
+ switch (table.version) {
15
+ case 1:
16
+ glyph.id = (glyph.id + table.deltaGlyphID) & 0xffff;
17
+ break;
18
+
19
+ case 2:
20
+ glyph.id = table.substitute.get(index);
21
+ break;
22
+ }
23
+
24
+ return true;
25
+ }
26
+
27
+ case 2: { // Multiple Substitution
28
+ let index = this.coverageIndex(table.coverage);
29
+ if (index !== -1) {
30
+ let sequence = table.sequences.get(index);
31
+
32
+ if (sequence.length === 0) {
33
+ // If the sequence length is zero, delete the glyph.
34
+ // The OpenType spec disallows this, but seems like Harfbuzz and Uniscribe allow it.
35
+ this.glyphs.splice(this.glyphIterator.index, 1);
36
+ return true;
37
+ }
38
+
39
+ this.glyphIterator.cur.id = sequence[0];
40
+ this.glyphIterator.cur.ligatureComponent = 0;
41
+
42
+ let features = this.glyphIterator.cur.features;
43
+ let curGlyph = this.glyphIterator.cur;
44
+ let replacement = sequence.slice(1).map((gid, i) => {
45
+ let glyph = new GlyphInfo(this.font, gid, undefined, features);
46
+ glyph.shaperInfo = curGlyph.shaperInfo;
47
+ glyph.isLigated = curGlyph.isLigated;
48
+ glyph.ligatureComponent = i + 1;
49
+ glyph.substituted = true;
50
+ glyph.isMultiplied = true;
51
+ return glyph;
52
+ });
53
+
54
+ this.glyphs.splice(this.glyphIterator.index + 1, 0, ...replacement);
55
+ return true;
56
+ }
57
+
58
+ return false;
59
+ }
60
+
61
+ case 3: { // Alternate Substitution
62
+ let index = this.coverageIndex(table.coverage);
63
+ if (index !== -1) {
64
+ let USER_INDEX = 0; // TODO
65
+ this.glyphIterator.cur.id = table.alternateSet.get(index)[USER_INDEX];
66
+ return true;
67
+ }
68
+
69
+ return false;
70
+ }
71
+
72
+ case 4: { // Ligature Substitution
73
+ let index = this.coverageIndex(table.coverage);
74
+ if (index === -1) {
75
+ return false;
76
+ }
77
+
78
+ for (let ligature of table.ligatureSets.get(index)) {
79
+ let matched = this.sequenceMatchIndices(1, ligature.components);
80
+ if (!matched) {
81
+ continue;
82
+ }
83
+
84
+ let curGlyph = this.glyphIterator.cur;
85
+
86
+ // Concatenate all of the characters the new ligature will represent
87
+ let characters = curGlyph.codePoints.slice();
88
+ for (let index of matched) {
89
+ characters.push(...this.glyphs[index].codePoints);
90
+ }
91
+
92
+ // Create the replacement ligature glyph
93
+ let ligatureGlyph = new GlyphInfo(this.font, ligature.glyph, characters, curGlyph.features);
94
+ ligatureGlyph.shaperInfo = curGlyph.shaperInfo;
95
+ ligatureGlyph.isLigated = true;
96
+ ligatureGlyph.substituted = true;
97
+
98
+ // From Harfbuzz:
99
+ // - If it *is* a mark ligature, we don't allocate a new ligature id, and leave
100
+ // the ligature to keep its old ligature id. This will allow it to attach to
101
+ // a base ligature in GPOS. Eg. if the sequence is: LAM,LAM,SHADDA,FATHA,HEH,
102
+ // and LAM,LAM,HEH for a ligature, they will leave SHADDA and FATHA with a
103
+ // ligature id and component value of 2. Then if SHADDA,FATHA form a ligature
104
+ // later, we don't want them to lose their ligature id/component, otherwise
105
+ // GPOS will fail to correctly position the mark ligature on top of the
106
+ // LAM,LAM,HEH ligature. See https://bugzilla.gnome.org/show_bug.cgi?id=676343
107
+ //
108
+ // - If a ligature is formed of components that some of which are also ligatures
109
+ // themselves, and those ligature components had marks attached to *their*
110
+ // components, we have to attach the marks to the new ligature component
111
+ // positions! Now *that*'s tricky! And these marks may be following the
112
+ // last component of the whole sequence, so we should loop forward looking
113
+ // for them and update them.
114
+ //
115
+ // Eg. the sequence is LAM,LAM,SHADDA,FATHA,HEH, and the font first forms a
116
+ // 'calt' ligature of LAM,HEH, leaving the SHADDA and FATHA with a ligature
117
+ // id and component == 1. Now, during 'liga', the LAM and the LAM-HEH ligature
118
+ // form a LAM-LAM-HEH ligature. We need to reassign the SHADDA and FATHA to
119
+ // the new ligature with a component value of 2.
120
+ //
121
+ // This in fact happened to a font... See https://bugzilla.gnome.org/show_bug.cgi?id=437633
122
+ let isMarkLigature = curGlyph.isMark;
123
+ for (let i = 0; i < matched.length && isMarkLigature; i++) {
124
+ isMarkLigature = this.glyphs[matched[i]].isMark;
125
+ }
126
+
127
+ ligatureGlyph.ligatureID = isMarkLigature ? null : this.ligatureID++;
128
+
129
+ let lastLigID = curGlyph.ligatureID;
130
+ let lastNumComps = curGlyph.codePoints.length;
131
+ let curComps = lastNumComps;
132
+ let idx = this.glyphIterator.index + 1;
133
+
134
+ // Set ligatureID and ligatureComponent on glyphs that were skipped in the matched sequence.
135
+ // This allows GPOS to attach marks to the correct ligature components.
136
+ for (let matchIndex of matched) {
137
+ // Don't assign new ligature components for mark ligatures (see above)
138
+ if (isMarkLigature) {
139
+ idx = matchIndex;
140
+ } else {
141
+ while (idx < matchIndex) {
142
+ var ligatureComponent = curComps - lastNumComps + Math.min(this.glyphs[idx].ligatureComponent || 1, lastNumComps);
143
+ this.glyphs[idx].ligatureID = ligatureGlyph.ligatureID;
144
+ this.glyphs[idx].ligatureComponent = ligatureComponent;
145
+ idx++;
146
+ }
147
+ }
148
+
149
+ lastLigID = this.glyphs[idx].ligatureID;
150
+ lastNumComps = this.glyphs[idx].codePoints.length;
151
+ curComps += lastNumComps;
152
+ idx++; // skip base glyph
153
+ }
154
+
155
+ // Adjust ligature components for any marks following
156
+ if (lastLigID && !isMarkLigature) {
157
+ for (let i = idx; i < this.glyphs.length; i++) {
158
+ if (this.glyphs[i].ligatureID === lastLigID) {
159
+ var ligatureComponent = curComps - lastNumComps + Math.min(this.glyphs[i].ligatureComponent || 1, lastNumComps);
160
+ this.glyphs[i].ligatureComponent = ligatureComponent;
161
+ } else {
162
+ break;
163
+ }
164
+ }
165
+ }
166
+
167
+ // Delete the matched glyphs, and replace the current glyph with the ligature glyph
168
+ for (let i = matched.length - 1; i >= 0; i--) {
169
+ this.glyphs.splice(matched[i], 1);
170
+ }
171
+
172
+ this.glyphs[this.glyphIterator.index] = ligatureGlyph;
173
+ return true;
174
+ }
175
+
176
+ return false;
177
+ }
178
+
179
+ case 5: // Contextual Substitution
180
+ return this.applyContext(table);
181
+
182
+ case 6: // Chaining Contextual Substitution
183
+ return this.applyChainingContext(table);
184
+
185
+ case 7: // Extension Substitution
186
+ return this.applyLookup(table.lookupType, table.extension);
187
+
188
+ default:
189
+ throw new Error(`GSUB lookupType ${lookupType} is not supported`);
190
+ }
191
+ }
192
+ }
node_modules/fontkit/src/opentype/GlyphInfo.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {isMark} from 'unicode-properties';
2
+ import OTProcessor from './OTProcessor';
3
+
4
+ export default class GlyphInfo {
5
+ constructor(font, id, codePoints = [], features) {
6
+ this._font = font;
7
+ this.codePoints = codePoints;
8
+ this.id = id;
9
+
10
+ this.features = {};
11
+ if (Array.isArray(features)) {
12
+ for (let i = 0; i < features.length; i++) {
13
+ let feature = features[i];
14
+ this.features[feature] = true;
15
+ }
16
+ } else if (typeof features === 'object') {
17
+ Object.assign(this.features, features);
18
+ }
19
+
20
+ this.ligatureID = null;
21
+ this.ligatureComponent = null;
22
+ this.isLigated = false;
23
+ this.cursiveAttachment = null;
24
+ this.markAttachment = null;
25
+ this.shaperInfo = null;
26
+ this.substituted = false;
27
+ this.isMultiplied = false;
28
+ }
29
+
30
+ get id() {
31
+ return this._id;
32
+ }
33
+
34
+ set id(id) {
35
+ this._id = id;
36
+ this.substituted = true;
37
+
38
+ let GDEF = this._font.GDEF;
39
+ if (GDEF && GDEF.glyphClassDef) {
40
+ // TODO: clean this up
41
+ let classID = OTProcessor.prototype.getClassID(id, GDEF.glyphClassDef);
42
+ this.isBase = classID === 1;
43
+ this.isLigature = classID === 2;
44
+ this.isMark = classID === 3;
45
+ this.markAttachmentType = GDEF.markAttachClassDef ? OTProcessor.prototype.getClassID(id, GDEF.markAttachClassDef) : 0;
46
+ } else {
47
+ this.isMark = this.codePoints.length > 0 && this.codePoints.every(isMark);
48
+ this.isBase = !this.isMark;
49
+ this.isLigature = this.codePoints.length > 1;
50
+ this.markAttachmentType = 0;
51
+ }
52
+ }
53
+
54
+ copy() {
55
+ return new GlyphInfo(this._font, this.id, this.codePoints, this.features);
56
+ }
57
+ }
node_modules/fontkit/src/opentype/GlyphIterator.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default class GlyphIterator {
2
+ constructor(glyphs, options) {
3
+ this.glyphs = glyphs;
4
+ this.reset(options);
5
+ }
6
+
7
+ reset(options = {}, index = 0) {
8
+ this.options = options;
9
+ this.flags = options.flags || {};
10
+ this.markAttachmentType = options.markAttachmentType || 0;
11
+ this.index = index;
12
+ }
13
+
14
+ get cur() {
15
+ return this.glyphs[this.index] || null;
16
+ }
17
+
18
+ shouldIgnore(glyph) {
19
+ return (this.flags.ignoreMarks && glyph.isMark) ||
20
+ (this.flags.ignoreBaseGlyphs && glyph.isBase) ||
21
+ (this.flags.ignoreLigatures && glyph.isLigature) ||
22
+ (this.markAttachmentType && glyph.isMark && glyph.markAttachmentType !== this.markAttachmentType);
23
+ }
24
+
25
+ move(dir) {
26
+ this.index += dir;
27
+ while (0 <= this.index && this.index < this.glyphs.length && this.shouldIgnore(this.glyphs[this.index])) {
28
+ this.index += dir;
29
+ }
30
+
31
+ if (0 > this.index || this.index >= this.glyphs.length) {
32
+ return null;
33
+ }
34
+
35
+ return this.glyphs[this.index];
36
+ }
37
+
38
+ next() {
39
+ return this.move(+1);
40
+ }
41
+
42
+ prev() {
43
+ return this.move(-1);
44
+ }
45
+
46
+ peek(count = 1) {
47
+ let idx = this.index;
48
+ let res = this.increment(count);
49
+ this.index = idx;
50
+ return res;
51
+ }
52
+
53
+ peekIndex(count = 1) {
54
+ let idx = this.index;
55
+ this.increment(count);
56
+ let res = this.index;
57
+ this.index = idx;
58
+ return res;
59
+ }
60
+
61
+ increment(count = 1) {
62
+ let dir = count < 0 ? -1 : 1;
63
+ count = Math.abs(count);
64
+ while (count--) {
65
+ this.move(dir);
66
+ }
67
+
68
+ return this.glyphs[this.index];
69
+ }
70
+ }
node_modules/fontkit/src/opentype/OTLayoutEngine.js ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ShapingPlan from './ShapingPlan';
2
+ import * as Shapers from './shapers';
3
+ import GlyphInfo from './GlyphInfo';
4
+ import GSUBProcessor from './GSUBProcessor';
5
+ import GPOSProcessor from './GPOSProcessor';
6
+
7
+ export default class OTLayoutEngine {
8
+ constructor(font) {
9
+ this.font = font;
10
+ this.glyphInfos = null;
11
+ this.plan = null;
12
+ this.GSUBProcessor = null;
13
+ this.GPOSProcessor = null;
14
+ this.fallbackPosition = true;
15
+
16
+ if (font.GSUB) {
17
+ this.GSUBProcessor = new GSUBProcessor(font, font.GSUB);
18
+ }
19
+
20
+ if (font.GPOS) {
21
+ this.GPOSProcessor = new GPOSProcessor(font, font.GPOS);
22
+ }
23
+ }
24
+
25
+ setup(glyphRun) {
26
+ // Map glyphs to GlyphInfo objects so data can be passed between
27
+ // GSUB and GPOS without mutating the real (shared) Glyph objects.
28
+ this.glyphInfos = glyphRun.glyphs.map(glyph => new GlyphInfo(this.font, glyph.id, [...glyph.codePoints]));
29
+
30
+ // Select a script based on what is available in GSUB/GPOS.
31
+ let script = null;
32
+ if (this.GPOSProcessor) {
33
+ script = this.GPOSProcessor.selectScript(glyphRun.script, glyphRun.language, glyphRun.direction);
34
+ }
35
+
36
+ if (this.GSUBProcessor) {
37
+ script = this.GSUBProcessor.selectScript(glyphRun.script, glyphRun.language, glyphRun.direction);
38
+ }
39
+
40
+ // Choose a shaper based on the script, and setup a shaping plan.
41
+ // This determines which features to apply to which glyphs.
42
+ this.shaper = Shapers.choose(script);
43
+ this.plan = new ShapingPlan(this.font, script, glyphRun.direction);
44
+ this.shaper.plan(this.plan, this.glyphInfos, glyphRun.features);
45
+
46
+ // Assign chosen features to output glyph run
47
+ for (let key in this.plan.allFeatures) {
48
+ glyphRun.features[key] = true;
49
+ }
50
+ }
51
+
52
+ substitute(glyphRun) {
53
+ if (this.GSUBProcessor) {
54
+ this.plan.process(this.GSUBProcessor, this.glyphInfos);
55
+
56
+ // Map glyph infos back to normal Glyph objects
57
+ glyphRun.glyphs = this.glyphInfos.map(glyphInfo => this.font.getGlyph(glyphInfo.id, glyphInfo.codePoints));
58
+ }
59
+ }
60
+
61
+ position(glyphRun) {
62
+ if (this.shaper.zeroMarkWidths === 'BEFORE_GPOS') {
63
+ this.zeroMarkAdvances(glyphRun.positions);
64
+ }
65
+
66
+ if (this.GPOSProcessor) {
67
+ this.plan.process(this.GPOSProcessor, this.glyphInfos, glyphRun.positions);
68
+ }
69
+
70
+ if (this.shaper.zeroMarkWidths === 'AFTER_GPOS') {
71
+ this.zeroMarkAdvances(glyphRun.positions);
72
+ }
73
+
74
+ // Reverse the glyphs and positions if the script is right-to-left
75
+ if (glyphRun.direction === 'rtl') {
76
+ glyphRun.glyphs.reverse();
77
+ glyphRun.positions.reverse();
78
+ }
79
+
80
+ return this.GPOSProcessor && this.GPOSProcessor.features;
81
+ }
82
+
83
+ zeroMarkAdvances(positions) {
84
+ for (let i = 0; i < this.glyphInfos.length; i++) {
85
+ if (this.glyphInfos[i].isMark) {
86
+ positions[i].xAdvance = 0;
87
+ positions[i].yAdvance = 0;
88
+ }
89
+ }
90
+ }
91
+
92
+ cleanup() {
93
+ this.glyphInfos = null;
94
+ this.plan = null;
95
+ this.shaper = null;
96
+ }
97
+
98
+ getAvailableFeatures(script, language) {
99
+ let features = [];
100
+
101
+ if (this.GSUBProcessor) {
102
+ this.GSUBProcessor.selectScript(script, language);
103
+ features.push(...Object.keys(this.GSUBProcessor.features));
104
+ }
105
+
106
+ if (this.GPOSProcessor) {
107
+ this.GPOSProcessor.selectScript(script, language);
108
+ features.push(...Object.keys(this.GPOSProcessor.features));
109
+ }
110
+
111
+ return features;
112
+ }
113
+ }
node_modules/fontkit/src/opentype/OTProcessor.js ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import GlyphIterator from './GlyphIterator';
2
+ import * as Script from '../layout/Script';
3
+
4
+ const DEFAULT_SCRIPTS = ['DFLT', 'dflt', 'latn'];
5
+
6
+ export default class OTProcessor {
7
+ constructor(font, table) {
8
+ this.font = font;
9
+ this.table = table;
10
+
11
+ this.script = null;
12
+ this.scriptTag = null;
13
+
14
+ this.language = null;
15
+ this.languageTag = null;
16
+
17
+ this.features = {};
18
+ this.lookups = {};
19
+
20
+ // Setup variation substitutions
21
+ this.variationsIndex = font._variationProcessor
22
+ ? this.findVariationsIndex(font._variationProcessor.normalizedCoords)
23
+ : -1;
24
+
25
+ // initialize to default script + language
26
+ this.selectScript();
27
+
28
+ // current context (set by applyFeatures)
29
+ this.glyphs = [];
30
+ this.positions = []; // only used by GPOS
31
+ this.ligatureID = 1;
32
+ this.currentFeature = null;
33
+ }
34
+
35
+ findScript(script) {
36
+ if (this.table.scriptList == null) {
37
+ return null;
38
+ }
39
+
40
+ if (!Array.isArray(script)) {
41
+ script = [script];
42
+ }
43
+
44
+ for (let s of script) {
45
+ for (let entry of this.table.scriptList) {
46
+ if (entry.tag === s) {
47
+ return entry;
48
+ }
49
+ }
50
+ }
51
+
52
+ return null;
53
+ }
54
+
55
+ selectScript(script, language, direction) {
56
+ let changed = false;
57
+ let entry;
58
+ if (!this.script || script !== this.scriptTag) {
59
+ entry = this.findScript(script);
60
+ if (!entry) {
61
+ entry = this.findScript(DEFAULT_SCRIPTS);
62
+ }
63
+
64
+ if (!entry) {
65
+ return this.scriptTag;
66
+ }
67
+
68
+ this.scriptTag = entry.tag;
69
+ this.script = entry.script;
70
+ this.language = null;
71
+ this.languageTag = null;
72
+ changed = true;
73
+ }
74
+
75
+ if (!direction || direction !== this.direction) {
76
+ this.direction = direction || Script.direction(script);
77
+ }
78
+
79
+ if (language && language.length < 4) {
80
+ language += ' '.repeat(4 - language.length);
81
+ }
82
+
83
+ if (!language || language !== this.languageTag) {
84
+ this.language = null;
85
+
86
+ for (let lang of this.script.langSysRecords) {
87
+ if (lang.tag === language) {
88
+ this.language = lang.langSys;
89
+ this.languageTag = lang.tag;
90
+ break;
91
+ }
92
+ }
93
+
94
+ if (!this.language) {
95
+ this.language = this.script.defaultLangSys;
96
+ this.languageTag = null;
97
+ }
98
+
99
+ changed = true;
100
+ }
101
+
102
+ // Build a feature lookup table
103
+ if (changed) {
104
+ this.features = {};
105
+ if (this.language) {
106
+ for (let featureIndex of this.language.featureIndexes) {
107
+ let record = this.table.featureList[featureIndex];
108
+ let substituteFeature = this.substituteFeatureForVariations(featureIndex);
109
+ this.features[record.tag] = substituteFeature || record.feature;
110
+ }
111
+ }
112
+ }
113
+
114
+ return this.scriptTag;
115
+ }
116
+
117
+ lookupsForFeatures(userFeatures = [], exclude) {
118
+ let lookups = [];
119
+ for (let tag of userFeatures) {
120
+ let feature = this.features[tag];
121
+ if (!feature) {
122
+ continue;
123
+ }
124
+
125
+ for (let lookupIndex of feature.lookupListIndexes) {
126
+ if (exclude && exclude.indexOf(lookupIndex) !== -1) {
127
+ continue;
128
+ }
129
+
130
+ lookups.push({
131
+ feature: tag,
132
+ index: lookupIndex,
133
+ lookup: this.table.lookupList.get(lookupIndex)
134
+ });
135
+ }
136
+ }
137
+
138
+ lookups.sort((a, b) => a.index - b.index);
139
+ return lookups;
140
+ }
141
+
142
+ substituteFeatureForVariations(featureIndex) {
143
+ if (this.variationsIndex === -1) {
144
+ return null;
145
+ }
146
+
147
+ let record = this.table.featureVariations.featureVariationRecords[this.variationsIndex];
148
+ let substitutions = record.featureTableSubstitution.substitutions;
149
+ for (let substitution of substitutions) {
150
+ if (substitution.featureIndex === featureIndex) {
151
+ return substitution.alternateFeatureTable;
152
+ }
153
+ }
154
+
155
+ return null;
156
+ }
157
+
158
+ findVariationsIndex(coords) {
159
+ let variations = this.table.featureVariations;
160
+ if (!variations) {
161
+ return -1;
162
+ }
163
+
164
+ let records = variations.featureVariationRecords;
165
+ for (let i = 0; i < records.length; i++) {
166
+ let conditions = records[i].conditionSet.conditionTable;
167
+ if (this.variationConditionsMatch(conditions, coords)) {
168
+ return i;
169
+ }
170
+ }
171
+
172
+ return -1;
173
+ }
174
+
175
+ variationConditionsMatch(conditions, coords) {
176
+ return conditions.every(condition => {
177
+ let coord = condition.axisIndex < coords.length ? coords[condition.axisIndex] : 0;
178
+ return condition.filterRangeMinValue <= coord && coord <= condition.filterRangeMaxValue;
179
+ });
180
+ }
181
+
182
+ applyFeatures(userFeatures, glyphs, advances) {
183
+ let lookups = this.lookupsForFeatures(userFeatures);
184
+ this.applyLookups(lookups, glyphs, advances);
185
+ }
186
+
187
+ applyLookups(lookups, glyphs, positions) {
188
+ this.glyphs = glyphs;
189
+ this.positions = positions;
190
+ this.glyphIterator = new GlyphIterator(glyphs);
191
+
192
+ for (let { feature, lookup } of lookups) {
193
+ this.currentFeature = feature;
194
+ this.glyphIterator.reset(lookup.flags);
195
+
196
+ while (this.glyphIterator.index < glyphs.length) {
197
+ if (!(feature in this.glyphIterator.cur.features)) {
198
+ this.glyphIterator.next();
199
+ continue;
200
+ }
201
+
202
+ for (let table of lookup.subTables) {
203
+ let res = this.applyLookup(lookup.lookupType, table);
204
+ if (res) {
205
+ break;
206
+ }
207
+ }
208
+
209
+ this.glyphIterator.next();
210
+ }
211
+ }
212
+ }
213
+
214
+ applyLookup(lookup, table) {
215
+ throw new Error("applyLookup must be implemented by subclasses");
216
+ }
217
+
218
+ applyLookupList(lookupRecords) {
219
+ let options = this.glyphIterator.options;
220
+ let glyphIndex = this.glyphIterator.index;
221
+
222
+ for (let lookupRecord of lookupRecords) {
223
+ // Reset flags and find glyph index for this lookup record
224
+ this.glyphIterator.reset(options, glyphIndex);
225
+ this.glyphIterator.increment(lookupRecord.sequenceIndex);
226
+
227
+ // Get the lookup and setup flags for subtables
228
+ let lookup = this.table.lookupList.get(lookupRecord.lookupListIndex);
229
+ this.glyphIterator.reset(lookup.flags, this.glyphIterator.index);
230
+
231
+ // Apply lookup subtables until one matches
232
+ for (let table of lookup.subTables) {
233
+ if (this.applyLookup(lookup.lookupType, table)) {
234
+ break;
235
+ }
236
+ }
237
+ }
238
+
239
+ this.glyphIterator.reset(options, glyphIndex);
240
+ return true;
241
+ }
242
+
243
+ coverageIndex(coverage, glyph) {
244
+ if (glyph == null) {
245
+ glyph = this.glyphIterator.cur.id;
246
+ }
247
+
248
+ switch (coverage.version) {
249
+ case 1:
250
+ return coverage.glyphs.indexOf(glyph);
251
+
252
+ case 2:
253
+ for (let range of coverage.rangeRecords) {
254
+ if (range.start <= glyph && glyph <= range.end) {
255
+ return range.startCoverageIndex + glyph - range.start;
256
+ }
257
+ }
258
+
259
+ break;
260
+ }
261
+
262
+ return -1;
263
+ }
264
+
265
+ match(sequenceIndex, sequence, fn, matched) {
266
+ let pos = this.glyphIterator.index;
267
+ let glyph = this.glyphIterator.increment(sequenceIndex);
268
+ let idx = 0;
269
+
270
+ while (idx < sequence.length && glyph && fn(sequence[idx], glyph)) {
271
+ if (matched) {
272
+ matched.push(this.glyphIterator.index);
273
+ }
274
+
275
+ idx++;
276
+ glyph = this.glyphIterator.next();
277
+ }
278
+
279
+ this.glyphIterator.index = pos;
280
+ if (idx < sequence.length) {
281
+ return false;
282
+ }
283
+
284
+ return matched || true;
285
+ }
286
+
287
+ sequenceMatches(sequenceIndex, sequence) {
288
+ return this.match(sequenceIndex, sequence, (component, glyph) => component === glyph.id);
289
+ }
290
+
291
+ sequenceMatchIndices(sequenceIndex, sequence) {
292
+ return this.match(sequenceIndex, sequence, (component, glyph) => {
293
+ // If the current feature doesn't apply to this glyph,
294
+ if (!(this.currentFeature in glyph.features)) {
295
+ return false;
296
+ }
297
+
298
+ return component === glyph.id;
299
+ }, []);
300
+ }
301
+
302
+ coverageSequenceMatches(sequenceIndex, sequence) {
303
+ return this.match(sequenceIndex, sequence, (coverage, glyph) =>
304
+ this.coverageIndex(coverage, glyph.id) >= 0
305
+ );
306
+ }
307
+
308
+ getClassID(glyph, classDef) {
309
+ switch (classDef.version) {
310
+ case 1: // Class array
311
+ let i = glyph - classDef.startGlyph;
312
+ if (i >= 0 && i < classDef.classValueArray.length) {
313
+ return classDef.classValueArray[i];
314
+ }
315
+
316
+ break;
317
+
318
+ case 2:
319
+ for (let range of classDef.classRangeRecord) {
320
+ if (range.start <= glyph && glyph <= range.end) {
321
+ return range.class;
322
+ }
323
+ }
324
+
325
+ break;
326
+ }
327
+
328
+ return 0;
329
+ }
330
+
331
+ classSequenceMatches(sequenceIndex, sequence, classDef) {
332
+ return this.match(sequenceIndex, sequence, (classID, glyph) =>
333
+ classID === this.getClassID(glyph.id, classDef)
334
+ );
335
+ }
336
+
337
+ applyContext(table) {
338
+ let index, set;
339
+ switch (table.version) {
340
+ case 1:
341
+ index = this.coverageIndex(table.coverage);
342
+ if (index === -1) {
343
+ return false;
344
+ }
345
+
346
+ set = table.ruleSets[index];
347
+ for (let rule of set) {
348
+ if (this.sequenceMatches(1, rule.input)) {
349
+ return this.applyLookupList(rule.lookupRecords);
350
+ }
351
+ }
352
+
353
+ break;
354
+
355
+ case 2:
356
+ if (this.coverageIndex(table.coverage) === -1) {
357
+ return false;
358
+ }
359
+
360
+ index = this.getClassID(this.glyphIterator.cur.id, table.classDef);
361
+ if (index === -1) {
362
+ return false;
363
+ }
364
+
365
+ set = table.classSet[index];
366
+ for (let rule of set) {
367
+ if (this.classSequenceMatches(1, rule.classes, table.classDef)) {
368
+ return this.applyLookupList(rule.lookupRecords);
369
+ }
370
+ }
371
+
372
+ break;
373
+
374
+ case 3:
375
+ if (this.coverageSequenceMatches(0, table.coverages)) {
376
+ return this.applyLookupList(table.lookupRecords);
377
+ }
378
+
379
+ break;
380
+ }
381
+
382
+ return false;
383
+ }
384
+
385
+ applyChainingContext(table) {
386
+ let index;
387
+ switch (table.version) {
388
+ case 1:
389
+ index = this.coverageIndex(table.coverage);
390
+ if (index === -1) {
391
+ return false;
392
+ }
393
+
394
+ let set = table.chainRuleSets[index];
395
+ for (let rule of set) {
396
+ if (this.sequenceMatches(-rule.backtrack.length, rule.backtrack)
397
+ && this.sequenceMatches(1, rule.input)
398
+ && this.sequenceMatches(1 + rule.input.length, rule.lookahead)) {
399
+ return this.applyLookupList(rule.lookupRecords);
400
+ }
401
+ }
402
+
403
+ break;
404
+
405
+ case 2:
406
+ if (this.coverageIndex(table.coverage) === -1) {
407
+ return false;
408
+ }
409
+
410
+ index = this.getClassID(this.glyphIterator.cur.id, table.inputClassDef);
411
+ let rules = table.chainClassSet[index];
412
+ if (!rules) {
413
+ return false;
414
+ }
415
+
416
+ for (let rule of rules) {
417
+ if (this.classSequenceMatches(-rule.backtrack.length, rule.backtrack, table.backtrackClassDef) &&
418
+ this.classSequenceMatches(1, rule.input, table.inputClassDef) &&
419
+ this.classSequenceMatches(1 + rule.input.length, rule.lookahead, table.lookaheadClassDef)) {
420
+ return this.applyLookupList(rule.lookupRecords);
421
+ }
422
+ }
423
+
424
+ break;
425
+
426
+ case 3:
427
+ if (this.coverageSequenceMatches(-table.backtrackGlyphCount, table.backtrackCoverage) &&
428
+ this.coverageSequenceMatches(0, table.inputCoverage) &&
429
+ this.coverageSequenceMatches(table.inputGlyphCount, table.lookaheadCoverage)) {
430
+ return this.applyLookupList(table.lookupRecords);
431
+ }
432
+
433
+ break;
434
+ }
435
+
436
+ return false;
437
+ }
438
+ }
node_modules/fontkit/src/opentype/ShapingPlan.js ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as Script from '../layout/Script';
2
+
3
+ /**
4
+ * ShapingPlans are used by the OpenType shapers to store which
5
+ * features should by applied, and in what order to apply them.
6
+ * The features are applied in groups called stages. A feature
7
+ * can be applied globally to all glyphs, or locally to only
8
+ * specific glyphs.
9
+ *
10
+ * @private
11
+ */
12
+ export default class ShapingPlan {
13
+ constructor(font, script, direction) {
14
+ this.font = font;
15
+ this.script = script;
16
+ this.direction = direction;
17
+ this.stages = [];
18
+ this.globalFeatures = {};
19
+ this.allFeatures = {};
20
+ }
21
+
22
+ /**
23
+ * Adds the given features to the last stage.
24
+ * Ignores features that have already been applied.
25
+ */
26
+ _addFeatures(features, global) {
27
+ let stageIndex = this.stages.length - 1;
28
+ let stage = this.stages[stageIndex];
29
+ for (let feature of features) {
30
+ if (this.allFeatures[feature] == null) {
31
+ stage.push(feature);
32
+ this.allFeatures[feature] = stageIndex;
33
+
34
+ if (global) {
35
+ this.globalFeatures[feature] = true;
36
+ }
37
+ }
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Add features to the last stage
43
+ */
44
+ add(arg, global = true) {
45
+ if (this.stages.length === 0) {
46
+ this.stages.push([]);
47
+ }
48
+
49
+ if (typeof arg === 'string') {
50
+ arg = [arg];
51
+ }
52
+
53
+ if (Array.isArray(arg)) {
54
+ this._addFeatures(arg, global);
55
+ } else if (typeof arg === 'object') {
56
+ this._addFeatures(arg.global || [], true);
57
+ this._addFeatures(arg.local || [], false);
58
+ } else {
59
+ throw new Error("Unsupported argument to ShapingPlan#add");
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Add a new stage
65
+ */
66
+ addStage(arg, global) {
67
+ if (typeof arg === 'function') {
68
+ this.stages.push(arg, []);
69
+ } else {
70
+ this.stages.push([]);
71
+ this.add(arg, global);
72
+ }
73
+ }
74
+
75
+ setFeatureOverrides(features) {
76
+ if (Array.isArray(features)) {
77
+ this.add(features);
78
+ } else if (typeof features === 'object') {
79
+ for (let tag in features) {
80
+ if (features[tag]) {
81
+ this.add(tag);
82
+ } else if (this.allFeatures[tag] != null) {
83
+ let stage = this.stages[this.allFeatures[tag]];
84
+ stage.splice(stage.indexOf(tag), 1);
85
+ delete this.allFeatures[tag];
86
+ delete this.globalFeatures[tag];
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Assigns the global features to the given glyphs
94
+ */
95
+ assignGlobalFeatures(glyphs) {
96
+ for (let glyph of glyphs) {
97
+ for (let feature in this.globalFeatures) {
98
+ glyph.features[feature] = true;
99
+ }
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Executes the planned stages using the given OTProcessor
105
+ */
106
+ process(processor, glyphs, positions) {
107
+ for (let stage of this.stages) {
108
+ if (typeof stage === 'function') {
109
+ if (!positions) {
110
+ stage(this.font, glyphs, this);
111
+ }
112
+
113
+ } else if (stage.length > 0) {
114
+ processor.applyFeatures(stage, glyphs, positions);
115
+ }
116
+ }
117
+ }
118
+ }
node_modules/fontkit/src/opentype/shapers/ArabicShaper.js ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import DefaultShaper from './DefaultShaper';
2
+ import {getCategory} from 'unicode-properties';
3
+ import UnicodeTrie from 'unicode-trie';
4
+ import { decodeBase64 } from '../../utils';
5
+
6
+ const trie = new UnicodeTrie(decodeBase64(require('fs').readFileSync(__dirname + '/data.trie', 'base64')));
7
+ const FEATURES = ['isol', 'fina', 'fin2', 'fin3', 'medi', 'med2', 'init'];
8
+
9
+ const ShapingClasses = {
10
+ Non_Joining: 0,
11
+ Left_Joining: 1,
12
+ Right_Joining: 2,
13
+ Dual_Joining: 3,
14
+ Join_Causing: 3,
15
+ ALAPH: 4,
16
+ 'DALATH RISH': 5,
17
+ Transparent: 6
18
+ };
19
+
20
+ const ISOL = 'isol';
21
+ const FINA = 'fina';
22
+ const FIN2 = 'fin2';
23
+ const FIN3 = 'fin3';
24
+ const MEDI = 'medi';
25
+ const MED2 = 'med2';
26
+ const INIT = 'init';
27
+ const NONE = null;
28
+
29
+ // Each entry is [prevAction, curAction, nextState]
30
+ const STATE_TABLE = [
31
+ // Non_Joining, Left_Joining, Right_Joining, Dual_Joining, ALAPH, DALATH RISH
32
+ // State 0: prev was U, not willing to join.
33
+ [ [ NONE, NONE, 0 ], [ NONE, ISOL, 2 ], [ NONE, ISOL, 1 ], [ NONE, ISOL, 2 ], [ NONE, ISOL, 1 ], [ NONE, ISOL, 6 ] ],
34
+
35
+ // State 1: prev was R or ISOL/ALAPH, not willing to join.
36
+ [ [ NONE, NONE, 0 ], [ NONE, ISOL, 2 ], [ NONE, ISOL, 1 ], [ NONE, ISOL, 2 ], [ NONE, FIN2, 5 ], [ NONE, ISOL, 6 ] ],
37
+
38
+ // State 2: prev was D/L in ISOL form, willing to join.
39
+ [ [ NONE, NONE, 0 ], [ NONE, ISOL, 2 ], [ INIT, FINA, 1 ], [ INIT, FINA, 3 ], [ INIT, FINA, 4 ], [ INIT, FINA, 6 ] ],
40
+
41
+ // State 3: prev was D in FINA form, willing to join.
42
+ [ [ NONE, NONE, 0 ], [ NONE, ISOL, 2 ], [ MEDI, FINA, 1 ], [ MEDI, FINA, 3 ], [ MEDI, FINA, 4 ], [ MEDI, FINA, 6 ] ],
43
+
44
+ // State 4: prev was FINA ALAPH, not willing to join.
45
+ [ [ NONE, NONE, 0 ], [ NONE, ISOL, 2 ], [ MED2, ISOL, 1 ], [ MED2, ISOL, 2 ], [ MED2, FIN2, 5 ], [ MED2, ISOL, 6 ] ],
46
+
47
+ // State 5: prev was FIN2/FIN3 ALAPH, not willing to join.
48
+ [ [ NONE, NONE, 0 ], [ NONE, ISOL, 2 ], [ ISOL, ISOL, 1 ], [ ISOL, ISOL, 2 ], [ ISOL, FIN2, 5 ], [ ISOL, ISOL, 6 ] ],
49
+
50
+ // State 6: prev was DALATH/RISH, not willing to join.
51
+ [ [ NONE, NONE, 0 ], [ NONE, ISOL, 2 ], [ NONE, ISOL, 1 ], [ NONE, ISOL, 2 ], [ NONE, FIN3, 5 ], [ NONE, ISOL, 6 ] ]
52
+ ];
53
+
54
+ /**
55
+ * This is a shaper for Arabic, and other cursive scripts.
56
+ * It uses data from ArabicShaping.txt in the Unicode database,
57
+ * compiled to a UnicodeTrie by generate-data.coffee.
58
+ *
59
+ * The shaping state machine was ported from Harfbuzz.
60
+ * https://github.com/behdad/harfbuzz/blob/master/src/hb-ot-shape-complex-arabic.cc
61
+ */
62
+ export default class ArabicShaper extends DefaultShaper {
63
+ static planFeatures(plan) {
64
+ plan.add(['ccmp', 'locl']);
65
+ for (let i = 0; i < FEATURES.length; i++) {
66
+ let feature = FEATURES[i];
67
+ plan.addStage(feature, false);
68
+ }
69
+
70
+ plan.addStage('mset');
71
+ }
72
+
73
+ static assignFeatures(plan, glyphs) {
74
+ super.assignFeatures(plan, glyphs);
75
+
76
+ let prev = -1;
77
+ let state = 0;
78
+ let actions = [];
79
+
80
+ // Apply the state machine to map glyphs to features
81
+ for (let i = 0; i < glyphs.length; i++) {
82
+ let curAction, prevAction;
83
+ var glyph = glyphs[i];
84
+ let type = getShapingClass(glyph.codePoints[0]);
85
+ if (type === ShapingClasses.Transparent) {
86
+ actions[i] = NONE;
87
+ continue;
88
+ }
89
+
90
+ [prevAction, curAction, state] = STATE_TABLE[state][type];
91
+
92
+ if (prevAction !== NONE && prev !== -1) {
93
+ actions[prev] = prevAction;
94
+ }
95
+
96
+ actions[i] = curAction;
97
+ prev = i;
98
+ }
99
+
100
+ // Apply the chosen features to their respective glyphs
101
+ for (let index = 0; index < glyphs.length; index++) {
102
+ let feature;
103
+ var glyph = glyphs[index];
104
+ if (feature = actions[index]) {
105
+ glyph.features[feature] = true;
106
+ }
107
+ }
108
+ }
109
+ }
110
+
111
+ function getShapingClass(codePoint) {
112
+ let res = trie.get(codePoint);
113
+ if (res) {
114
+ return res - 1;
115
+ }
116
+
117
+ let category = getCategory(codePoint);
118
+ if (category === 'Mn' || category === 'Me' || category === 'Cf') {
119
+ return ShapingClasses.Transparent;
120
+ }
121
+
122
+ return ShapingClasses.Non_Joining;
123
+ }
node_modules/fontkit/src/opentype/shapers/DefaultShaper.js ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {isDigit} from 'unicode-properties';
2
+
3
+ const VARIATION_FEATURES = ['rvrn'];
4
+ const COMMON_FEATURES = ['ccmp', 'locl', 'rlig', 'mark', 'mkmk'];
5
+ const FRACTIONAL_FEATURES = ['frac', 'numr', 'dnom'];
6
+ const HORIZONTAL_FEATURES = ['calt', 'clig', 'liga', 'rclt', 'curs', 'kern'];
7
+ const VERTICAL_FEATURES = ['vert'];
8
+ const DIRECTIONAL_FEATURES = {
9
+ ltr: ['ltra', 'ltrm'],
10
+ rtl: ['rtla', 'rtlm']
11
+ };
12
+
13
+ export default class DefaultShaper {
14
+ static zeroMarkWidths = 'AFTER_GPOS';
15
+ static plan(plan, glyphs, features) {
16
+ // Plan the features we want to apply
17
+ this.planPreprocessing(plan);
18
+ this.planFeatures(plan);
19
+ this.planPostprocessing(plan, features);
20
+
21
+ // Assign the global features to all the glyphs
22
+ plan.assignGlobalFeatures(glyphs);
23
+
24
+ // Assign local features to glyphs
25
+ this.assignFeatures(plan, glyphs);
26
+ }
27
+
28
+ static planPreprocessing(plan) {
29
+ plan.add({
30
+ global: [...VARIATION_FEATURES, ...DIRECTIONAL_FEATURES[plan.direction]],
31
+ local: FRACTIONAL_FEATURES
32
+ });
33
+ }
34
+
35
+ static planFeatures(plan) {
36
+ // Do nothing by default. Let subclasses override this.
37
+ }
38
+
39
+ static planPostprocessing(plan, userFeatures) {
40
+ plan.add([...COMMON_FEATURES, ...HORIZONTAL_FEATURES]);
41
+ plan.setFeatureOverrides(userFeatures);
42
+ }
43
+
44
+ static assignFeatures(plan, glyphs) {
45
+ // Enable contextual fractions
46
+ for (let i = 0; i < glyphs.length; i++) {
47
+ let glyph = glyphs[i];
48
+ if (glyph.codePoints[0] === 0x2044) { // fraction slash
49
+ let start = i;
50
+ let end = i + 1;
51
+
52
+ // Apply numerator
53
+ while (start > 0 && isDigit(glyphs[start - 1].codePoints[0])) {
54
+ glyphs[start - 1].features.numr = true;
55
+ glyphs[start - 1].features.frac = true;
56
+ start--;
57
+ }
58
+
59
+ // Apply denominator
60
+ while (end < glyphs.length && isDigit(glyphs[end].codePoints[0])) {
61
+ glyphs[end].features.dnom = true;
62
+ glyphs[end].features.frac = true;
63
+ end++;
64
+ }
65
+
66
+ // Apply fraction slash
67
+ glyph.features.frac = true;
68
+ i = end - 1;
69
+ }
70
+ }
71
+ }
72
+ }
node_modules/fontkit/src/opentype/shapers/HangulShaper.js ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import DefaultShaper from './DefaultShaper';
2
+ import GlyphInfo from '../GlyphInfo';
3
+
4
+ /**
5
+ * This is a shaper for the Hangul script, used by the Korean language.
6
+ * It does the following:
7
+ * - decompose if unsupported by the font:
8
+ * <LV> -> <L,V>
9
+ * <LVT> -> <L,V,T>
10
+ * <LV,T> -> <L,V,T>
11
+ *
12
+ * - compose if supported by the font:
13
+ * <L,V> -> <LV>
14
+ * <L,V,T> -> <LVT>
15
+ * <LV,T> -> <LVT>
16
+ *
17
+ * - reorder tone marks (S is any valid syllable):
18
+ * <S, M> -> <M, S>
19
+ *
20
+ * - apply ljmo, vjmo, and tjmo OpenType features to decomposed Jamo sequences.
21
+ *
22
+ * This logic is based on the following documents:
23
+ * - http://www.microsoft.com/typography/OpenTypeDev/hangul/intro.htm
24
+ * - http://ktug.org/~nomos/harfbuzz-hangul/hangulshaper.pdf
25
+ */
26
+ export default class HangulShaper extends DefaultShaper {
27
+ static zeroMarkWidths = 'NONE';
28
+ static planFeatures(plan) {
29
+ plan.add(['ljmo', 'vjmo', 'tjmo'], false);
30
+ }
31
+
32
+ static assignFeatures(plan, glyphs) {
33
+ let state = 0;
34
+ let i = 0;
35
+ while (i < glyphs.length) {
36
+ let action;
37
+ let glyph = glyphs[i];
38
+ let code = glyph.codePoints[0];
39
+ let type = getType(code);
40
+
41
+ [ action, state ] = STATE_TABLE[state][type];
42
+
43
+ switch (action) {
44
+ case DECOMPOSE:
45
+ // Decompose the composed syllable if it is not supported by the font.
46
+ if (!plan.font.hasGlyphForCodePoint(code)) {
47
+ i = decompose(glyphs, i, plan.font);
48
+ }
49
+ break;
50
+
51
+ case COMPOSE:
52
+ // Found a decomposed syllable. Try to compose if supported by the font.
53
+ i = compose(glyphs, i, plan.font);
54
+ break;
55
+
56
+ case TONE_MARK:
57
+ // Got a valid syllable, followed by a tone mark. Move the tone mark to the beginning of the syllable.
58
+ reorderToneMark(glyphs, i, plan.font);
59
+ break;
60
+
61
+ case INVALID:
62
+ // Tone mark has no valid syllable to attach to, so insert a dotted circle
63
+ i = insertDottedCircle(glyphs, i, plan.font);
64
+ break;
65
+ }
66
+
67
+ i++;
68
+ }
69
+ }
70
+ }
71
+
72
+ const HANGUL_BASE = 0xac00;
73
+ const HANGUL_END = 0xd7a4;
74
+ const HANGUL_COUNT = HANGUL_END - HANGUL_BASE + 1;
75
+ const L_BASE = 0x1100; // lead
76
+ const V_BASE = 0x1161; // vowel
77
+ const T_BASE = 0x11a7; // trail
78
+ const L_COUNT = 19;
79
+ const V_COUNT = 21;
80
+ const T_COUNT = 28;
81
+ const L_END = L_BASE + L_COUNT - 1;
82
+ const V_END = V_BASE + V_COUNT - 1;
83
+ const T_END = T_BASE + T_COUNT - 1;
84
+ const DOTTED_CIRCLE = 0x25cc;
85
+
86
+ const isL = code => 0x1100 <= code && code <= 0x115f || 0xa960 <= code && code <= 0xa97c;
87
+ const isV = code => 0x1160 <= code && code <= 0x11a7 || 0xd7b0 <= code && code <= 0xd7c6;
88
+ const isT = code => 0x11a8 <= code && code <= 0x11ff || 0xd7cb <= code && code <= 0xd7fb;
89
+ const isTone = code => 0x302e <= code && code <= 0x302f;
90
+ const isLVT = code => HANGUL_BASE <= code && code <= HANGUL_END;
91
+ const isLV = code => (code - HANGUL_BASE) < HANGUL_COUNT && (code - HANGUL_BASE) % T_COUNT === 0;
92
+ const isCombiningL = code => L_BASE <= code && code <= L_END;
93
+ const isCombiningV = code => V_BASE <= code && code <= V_END;
94
+ const isCombiningT = code => T_BASE + 1 && 1 <= code && code <= T_END;
95
+
96
+ // Character categories
97
+ const X = 0; // Other character
98
+ const L = 1; // Leading consonant
99
+ const V = 2; // Medial vowel
100
+ const T = 3; // Trailing consonant
101
+ const LV = 4; // Composed <LV> syllable
102
+ const LVT = 5; // Composed <LVT> syllable
103
+ const M = 6; // Tone mark
104
+
105
+ // This function classifies a character using the above categories.
106
+ function getType(code) {
107
+ if (isL(code)) { return L; }
108
+ if (isV(code)) { return V; }
109
+ if (isT(code)) { return T; }
110
+ if (isLV(code)) { return LV; }
111
+ if (isLVT(code)) { return LVT; }
112
+ if (isTone(code)) { return M; }
113
+ return X;
114
+ }
115
+
116
+ // State machine actions
117
+ const NO_ACTION = 0;
118
+ const DECOMPOSE = 1;
119
+ const COMPOSE = 2;
120
+ const TONE_MARK = 4;
121
+ const INVALID = 5;
122
+
123
+ // Build a state machine that accepts valid syllables, and applies actions along the way.
124
+ // The logic this is implementing is documented at the top of the file.
125
+ const STATE_TABLE = [
126
+ // X L V T LV LVT M
127
+ // State 0: start state
128
+ [ [ NO_ACTION, 0 ], [ NO_ACTION, 1 ], [ NO_ACTION, 0 ], [ NO_ACTION, 0 ], [ DECOMPOSE, 2 ], [ DECOMPOSE, 3 ], [ INVALID, 0 ] ],
129
+
130
+ // State 1: <L>
131
+ [ [ NO_ACTION, 0 ], [ NO_ACTION, 1 ], [ COMPOSE, 2 ], [ NO_ACTION, 0 ], [ DECOMPOSE, 2 ], [ DECOMPOSE, 3 ], [ INVALID, 0 ] ],
132
+
133
+ // State 2: <L,V> or <LV>
134
+ [ [ NO_ACTION, 0 ], [ NO_ACTION, 1 ], [ NO_ACTION, 0 ], [ COMPOSE, 3 ], [ DECOMPOSE, 2 ], [ DECOMPOSE, 3 ], [ TONE_MARK, 0 ] ],
135
+
136
+ // State 3: <L,V,T> or <LVT>
137
+ [ [ NO_ACTION, 0 ], [ NO_ACTION, 1 ], [ NO_ACTION, 0 ], [ NO_ACTION, 0 ], [ DECOMPOSE, 2 ], [ DECOMPOSE, 3 ], [ TONE_MARK, 0 ] ]
138
+ ];
139
+
140
+ function getGlyph(font, code, features) {
141
+ return new GlyphInfo(font, font.glyphForCodePoint(code).id, [code], features);
142
+ }
143
+
144
+ function decompose(glyphs, i, font) {
145
+ let glyph = glyphs[i];
146
+ let code = glyph.codePoints[0];
147
+
148
+ let s = code - HANGUL_BASE;
149
+ let t = T_BASE + s % T_COUNT;
150
+ s = s / T_COUNT | 0;
151
+ let l = L_BASE + s / V_COUNT | 0;
152
+ let v = V_BASE + s % V_COUNT;
153
+
154
+ // Don't decompose if all of the components are not available
155
+ if (!font.hasGlyphForCodePoint(l) ||
156
+ !font.hasGlyphForCodePoint(v) ||
157
+ (t !== T_BASE && !font.hasGlyphForCodePoint(t))) {
158
+ return i;
159
+ }
160
+
161
+ // Replace the current glyph with decomposed L, V, and T glyphs,
162
+ // and apply the proper OpenType features to each component.
163
+ let ljmo = getGlyph(font, l, glyph.features);
164
+ ljmo.features.ljmo = true;
165
+
166
+ let vjmo = getGlyph(font, v, glyph.features);
167
+ vjmo.features.vjmo = true;
168
+
169
+ let insert = [ ljmo, vjmo ];
170
+
171
+ if (t > T_BASE) {
172
+ let tjmo = getGlyph(font, t, glyph.features);
173
+ tjmo.features.tjmo = true;
174
+ insert.push(tjmo);
175
+ }
176
+
177
+ glyphs.splice(i, 1, ...insert);
178
+ return i + insert.length - 1;
179
+ }
180
+
181
+ function compose(glyphs, i, font) {
182
+ let glyph = glyphs[i];
183
+ let code = glyphs[i].codePoints[0];
184
+ let type = getType(code);
185
+
186
+ let prev = glyphs[i - 1].codePoints[0];
187
+ let prevType = getType(prev);
188
+
189
+ // Figure out what type of syllable we're dealing with
190
+ let lv, ljmo, vjmo, tjmo;
191
+ if (prevType === LV && type === T) {
192
+ // <LV,T>
193
+ lv = prev;
194
+ tjmo = glyph;
195
+ } else {
196
+ if (type === V) {
197
+ // <L,V>
198
+ ljmo = glyphs[i - 1];
199
+ vjmo = glyph;
200
+ } else {
201
+ // <L,V,T>
202
+ ljmo = glyphs[i - 2];
203
+ vjmo = glyphs[i - 1];
204
+ tjmo = glyph;
205
+ }
206
+
207
+ let l = ljmo.codePoints[0];
208
+ let v = vjmo.codePoints[0];
209
+
210
+ // Make sure L and V are combining characters
211
+ if (isCombiningL(l) && isCombiningV(v)) {
212
+ lv = HANGUL_BASE + ((l - L_BASE) * V_COUNT + (v - V_BASE)) * T_COUNT;
213
+ }
214
+ }
215
+
216
+ let t = (tjmo && tjmo.codePoints[0]) || T_BASE;
217
+ if ((lv != null) && (t === T_BASE || isCombiningT(t))) {
218
+ let s = lv + (t - T_BASE);
219
+
220
+ // Replace with a composed glyph if supported by the font,
221
+ // otherwise apply the proper OpenType features to each component.
222
+ if (font.hasGlyphForCodePoint(s)) {
223
+ let del = prevType === V ? 3 : 2;
224
+ glyphs.splice(i - del + 1, del, getGlyph(font, s, glyph.features));
225
+ return i - del + 1;
226
+ }
227
+ }
228
+
229
+ // Didn't compose (either a non-combining component or unsupported by font).
230
+ if (ljmo) { ljmo.features.ljmo = true; }
231
+ if (vjmo) { vjmo.features.vjmo = true; }
232
+ if (tjmo) { tjmo.features.tjmo = true; }
233
+
234
+ if (prevType === LV) {
235
+ // Sequence was originally <L,V>, which got combined earlier.
236
+ // Either the T was non-combining, or the LVT glyph wasn't supported.
237
+ // Decompose the glyph again and apply OT features.
238
+ decompose(glyphs, i - 1, font);
239
+ return i + 1;
240
+ }
241
+
242
+ return i;
243
+ }
244
+
245
+ function getLength(code) {
246
+ switch (getType(code)) {
247
+ case LV:
248
+ case LVT:
249
+ return 1;
250
+ case V:
251
+ return 2;
252
+ case T:
253
+ return 3;
254
+ }
255
+ }
256
+
257
+ function reorderToneMark(glyphs, i, font) {
258
+ let glyph = glyphs[i];
259
+ let code = glyphs[i].codePoints[0];
260
+
261
+ // Move tone mark to the beginning of the previous syllable, unless it is zero width
262
+ if (font.glyphForCodePoint(code).advanceWidth === 0) { return; }
263
+
264
+ let prev = glyphs[i - 1].codePoints[0];
265
+ let len = getLength(prev);
266
+
267
+ glyphs.splice(i, 1);
268
+ return glyphs.splice(i - len, 0, glyph);
269
+ }
270
+
271
+ function insertDottedCircle(glyphs, i, font) {
272
+ let glyph = glyphs[i];
273
+ let code = glyphs[i].codePoints[0];
274
+
275
+ if (font.hasGlyphForCodePoint(DOTTED_CIRCLE)) {
276
+ let dottedCircle = getGlyph(font, DOTTED_CIRCLE, glyph.features);
277
+
278
+ // If the tone mark is zero width, insert the dotted circle before, otherwise after
279
+ let idx = font.glyphForCodePoint(code).advanceWidth === 0 ? i : i + 1;
280
+ glyphs.splice(idx, 0, dottedCircle);
281
+ i++;
282
+ }
283
+
284
+ return i;
285
+ }
node_modules/fontkit/src/opentype/shapers/IndicShaper.js ADDED
@@ -0,0 +1,911 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import DefaultShaper from './DefaultShaper';
2
+ import StateMachine from 'dfa';
3
+ import UnicodeTrie from 'unicode-trie';
4
+ import {getCategory} from 'unicode-properties';
5
+ import * as Script from '../../layout/Script';
6
+ import GlyphInfo from '../GlyphInfo';
7
+ import indicMachine from './indic.json';
8
+ import useData from './use.json';
9
+ import {
10
+ CATEGORIES,
11
+ POSITIONS,
12
+ CONSONANT_FLAGS,
13
+ JOINER_FLAGS,
14
+ HALANT_OR_COENG_FLAGS, INDIC_CONFIGS,
15
+ INDIC_DECOMPOSITIONS
16
+ } from './indic-data';
17
+ import { decodeBase64 } from '../../utils';
18
+
19
+ const {decompositions} = useData;
20
+ const trie = new UnicodeTrie(decodeBase64(require('fs').readFileSync(__dirname + '/indic.trie', 'base64')));
21
+ const stateMachine = new StateMachine(indicMachine);
22
+
23
+ /**
24
+ * The IndicShaper supports indic scripts e.g. Devanagari, Kannada, etc.
25
+ * Based on code from Harfbuzz: https://github.com/behdad/harfbuzz/blob/master/src/hb-ot-shape-complex-indic.cc
26
+ */
27
+ export default class IndicShaper extends DefaultShaper {
28
+ static zeroMarkWidths = 'NONE';
29
+ static planFeatures(plan) {
30
+ plan.addStage(setupSyllables);
31
+
32
+ plan.addStage(['locl', 'ccmp']);
33
+
34
+ plan.addStage(initialReordering);
35
+
36
+ plan.addStage('nukt');
37
+ plan.addStage('akhn');
38
+ plan.addStage('rphf', false);
39
+ plan.addStage('rkrf');
40
+ plan.addStage('pref', false);
41
+ plan.addStage('blwf', false);
42
+ plan.addStage('abvf', false);
43
+ plan.addStage('half', false);
44
+ plan.addStage('pstf', false);
45
+ plan.addStage('vatu');
46
+ plan.addStage('cjct');
47
+ plan.addStage('cfar', false);
48
+
49
+ plan.addStage(finalReordering);
50
+
51
+ plan.addStage({
52
+ local: ['init'],
53
+ global: ['pres', 'abvs', 'blws', 'psts', 'haln', 'dist', 'abvm', 'blwm', 'calt', 'clig']
54
+ });
55
+
56
+ // Setup the indic config for the selected script
57
+ plan.unicodeScript = Script.fromOpenType(plan.script);
58
+ plan.indicConfig = INDIC_CONFIGS[plan.unicodeScript] || INDIC_CONFIGS.Default;
59
+ plan.isOldSpec = plan.indicConfig.hasOldSpec && plan.script[plan.script.length - 1] !== '2';
60
+
61
+ // TODO: turn off kern (Khmer) and liga features.
62
+ }
63
+
64
+ static assignFeatures(plan, glyphs) {
65
+ // Decompose split matras
66
+ // TODO: do this in a more general unicode normalizer
67
+ for (let i = glyphs.length - 1; i >= 0; i--) {
68
+ let codepoint = glyphs[i].codePoints[0];
69
+ let d = INDIC_DECOMPOSITIONS[codepoint] || decompositions[codepoint];
70
+ if (d) {
71
+ let decomposed = d.map(c => {
72
+ let g = plan.font.glyphForCodePoint(c);
73
+ return new GlyphInfo(plan.font, g.id, [c], glyphs[i].features);
74
+ });
75
+
76
+ glyphs.splice(i, 1, ...decomposed);
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ function indicCategory(glyph) {
83
+ return trie.get(glyph.codePoints[0]) >> 8;
84
+ }
85
+
86
+ function indicPosition(glyph) {
87
+ return 1 << (trie.get(glyph.codePoints[0]) & 0xff);
88
+ }
89
+
90
+ class IndicInfo {
91
+ constructor(category, position, syllableType, syllable) {
92
+ this.category = category;
93
+ this.position = position;
94
+ this.syllableType = syllableType;
95
+ this.syllable = syllable;
96
+ }
97
+ }
98
+
99
+ function setupSyllables(font, glyphs) {
100
+ let syllable = 0;
101
+ let last = 0;
102
+ for (let [start, end, tags] of stateMachine.match(glyphs.map(indicCategory))) {
103
+ if (start > last) {
104
+ ++syllable;
105
+ for (let i = last; i < start; i++) {
106
+ glyphs[i].shaperInfo = new IndicInfo(CATEGORIES.X, POSITIONS.End, 'non_indic_cluster', syllable);
107
+ }
108
+ }
109
+
110
+ ++syllable;
111
+
112
+ // Create shaper info
113
+ for (let i = start; i <= end; i++) {
114
+ glyphs[i].shaperInfo = new IndicInfo(
115
+ 1 << indicCategory(glyphs[i]),
116
+ indicPosition(glyphs[i]),
117
+ tags[0],
118
+ syllable
119
+ );
120
+ }
121
+
122
+ last = end + 1;
123
+ }
124
+
125
+ if (last < glyphs.length) {
126
+ ++syllable;
127
+ for (let i = last; i < glyphs.length; i++) {
128
+ glyphs[i].shaperInfo = new IndicInfo(CATEGORIES.X, POSITIONS.End, 'non_indic_cluster', syllable);
129
+ }
130
+ }
131
+ }
132
+
133
+ function isConsonant(glyph) {
134
+ return glyph.shaperInfo.category & CONSONANT_FLAGS;
135
+ }
136
+
137
+ function isJoiner(glyph) {
138
+ return glyph.shaperInfo.category & JOINER_FLAGS;
139
+ }
140
+
141
+ function isHalantOrCoeng(glyph) {
142
+ return glyph.shaperInfo.category & HALANT_OR_COENG_FLAGS;
143
+ }
144
+
145
+ function wouldSubstitute(glyphs, feature) {
146
+ for (let glyph of glyphs) {
147
+ glyph.features = {[feature]: true};
148
+ }
149
+
150
+ let GSUB = glyphs[0]._font._layoutEngine.engine.GSUBProcessor;
151
+ GSUB.applyFeatures([feature], glyphs);
152
+
153
+ return glyphs.length === 1;
154
+ }
155
+
156
+ function consonantPosition(font, consonant, virama) {
157
+ let glyphs = [virama, consonant, virama];
158
+ if (wouldSubstitute(glyphs.slice(0, 2), 'blwf') || wouldSubstitute(glyphs.slice(1, 3), 'blwf')) {
159
+ return POSITIONS.Below_C;
160
+ } else if (wouldSubstitute(glyphs.slice(0, 2), 'pstf') || wouldSubstitute(glyphs.slice(1, 3), 'pstf')) {
161
+ return POSITIONS.Post_C;
162
+ } else if (wouldSubstitute(glyphs.slice(0, 2), 'pref') || wouldSubstitute(glyphs.slice(1, 3), 'pref')) {
163
+ return POSITIONS.Post_C;
164
+ }
165
+
166
+ return POSITIONS.Base_C;
167
+ }
168
+
169
+ function initialReordering(font, glyphs, plan) {
170
+ let indicConfig = plan.indicConfig;
171
+ let features = font._layoutEngine.engine.GSUBProcessor.features;
172
+
173
+ let dottedCircle = font.glyphForCodePoint(0x25cc).id;
174
+ let virama = font.glyphForCodePoint(indicConfig.virama).id;
175
+ if (virama) {
176
+ let info = new GlyphInfo(font, virama, [indicConfig.virama]);
177
+ for (let i = 0; i < glyphs.length; i++) {
178
+ if (glyphs[i].shaperInfo.position === POSITIONS.Base_C) {
179
+ glyphs[i].shaperInfo.position = consonantPosition(font, glyphs[i].copy(), info);
180
+ }
181
+ }
182
+ }
183
+
184
+ for (let start = 0, end = nextSyllable(glyphs, 0); start < glyphs.length; start = end, end = nextSyllable(glyphs, start)) {
185
+ let {category, syllableType} = glyphs[start].shaperInfo;
186
+
187
+ if (syllableType === 'symbol_cluster' || syllableType === 'non_indic_cluster') {
188
+ continue;
189
+ }
190
+
191
+ if (syllableType === 'broken_cluster' && dottedCircle) {
192
+ let g = new GlyphInfo(font, dottedCircle, [0x25cc]);
193
+ g.shaperInfo = new IndicInfo(
194
+ 1 << indicCategory(g),
195
+ indicPosition(g),
196
+ glyphs[start].shaperInfo.syllableType,
197
+ glyphs[start].shaperInfo.syllable
198
+ );
199
+
200
+ // Insert after possible Repha.
201
+ let i = start;
202
+ while (i < end && glyphs[i].shaperInfo.category === CATEGORIES.Repha) {
203
+ i++;
204
+ }
205
+
206
+ glyphs.splice(i++, 0, g);
207
+ end++;
208
+ }
209
+
210
+ // 1. Find base consonant:
211
+ //
212
+ // The shaping engine finds the base consonant of the syllable, using the
213
+ // following algorithm: starting from the end of the syllable, move backwards
214
+ // until a consonant is found that does not have a below-base or post-base
215
+ // form (post-base forms have to follow below-base forms), or that is not a
216
+ // pre-base reordering Ra, or arrive at the first consonant. The consonant
217
+ // stopped at will be the base.
218
+
219
+ let base = end;
220
+ let limit = start;
221
+ let hasReph = false;
222
+
223
+ // If the syllable starts with Ra + Halant (in a script that has Reph)
224
+ // and has more than one consonant, Ra is excluded from candidates for
225
+ // base consonants.
226
+ if (indicConfig.rephPos !== POSITIONS.Ra_To_Become_Reph &&
227
+ features.rphf &&
228
+ start + 3 <= end && (
229
+ (indicConfig.rephMode === 'Implicit' && !isJoiner(glyphs[start + 2])) ||
230
+ (indicConfig.rephMode === 'Explicit' && glyphs[start + 2].shaperInfo.category === CATEGORIES.ZWJ)
231
+ )
232
+ ) {
233
+ // See if it matches the 'rphf' feature.
234
+ let g = [glyphs[start].copy(), glyphs[start + 1].copy(), glyphs[start + 2].copy()];
235
+ if (wouldSubstitute(g.slice(0, 2), 'rphf') || (indicConfig.rephMode === 'Explicit' && wouldSubstitute(g, 'rphf'))) {
236
+ limit += 2;
237
+ while (limit < end && isJoiner(glyphs[limit])) {
238
+ limit++;
239
+ }
240
+ base = start;
241
+ hasReph = true;
242
+ }
243
+ } else if (indicConfig.rephMode === 'Log_Repha' && glyphs[start].shaperInfo.category === CATEGORIES.Repha) {
244
+ limit++;
245
+ while (limit < end && isJoiner(glyphs[limit])) {
246
+ limit++;
247
+ }
248
+ base = start;
249
+ hasReph = true;
250
+ }
251
+
252
+ switch (indicConfig.basePos) {
253
+ case 'Last': {
254
+ // starting from the end of the syllable, move backwards
255
+ let i = end;
256
+ let seenBelow = false;
257
+
258
+ do {
259
+ let info = glyphs[--i].shaperInfo;
260
+
261
+ // until a consonant is found
262
+ if (isConsonant(glyphs[i])) {
263
+ // that does not have a below-base or post-base form
264
+ // (post-base forms have to follow below-base forms),
265
+ if (info.position !== POSITIONS.Below_C && (info.position !== POSITIONS.Post_C || seenBelow)) {
266
+ base = i;
267
+ break;
268
+ }
269
+
270
+ // or that is not a pre-base reordering Ra,
271
+ //
272
+ // IMPLEMENTATION NOTES:
273
+ //
274
+ // Our pre-base reordering Ra's are marked POS_POST_C, so will be skipped
275
+ // by the logic above already.
276
+ //
277
+
278
+ // or arrive at the first consonant. The consonant stopped at will
279
+ // be the base.
280
+ if (info.position === POSITIONS.Below_C) {
281
+ seenBelow = true;
282
+ }
283
+
284
+ base = i;
285
+ } else if (start < i && info.category === CATEGORIES.ZWJ && glyphs[i - 1].shaperInfo.category === CATEGORIES.H) {
286
+ // A ZWJ after a Halant stops the base search, and requests an explicit
287
+ // half form.
288
+ // A ZWJ before a Halant, requests a subjoined form instead, and hence
289
+ // search continues. This is particularly important for Bengali
290
+ // sequence Ra,H,Ya that should form Ya-Phalaa by subjoining Ya.
291
+ break;
292
+ }
293
+ } while (i > limit);
294
+ break;
295
+ }
296
+
297
+ case 'First': {
298
+ // The first consonant is always the base.
299
+ base = start;
300
+
301
+ // Mark all subsequent consonants as below.
302
+ for (let i = base + 1; i < end; i++) {
303
+ if (isConsonant(glyphs[i])) {
304
+ glyphs[i].shaperInfo.position = POSITIONS.Below_C;
305
+ }
306
+ }
307
+ }
308
+ }
309
+
310
+ // If the syllable starts with Ra + Halant (in a script that has Reph)
311
+ // and has more than one consonant, Ra is excluded from candidates for
312
+ // base consonants.
313
+ //
314
+ // Only do this for unforced Reph. (ie. not for Ra,H,ZWJ)
315
+ if (hasReph && base === start && limit - base <= 2) {
316
+ hasReph = false;
317
+ }
318
+
319
+ // 2. Decompose and reorder Matras:
320
+ //
321
+ // Each matra and any syllable modifier sign in the cluster are moved to the
322
+ // appropriate position relative to the consonant(s) in the cluster. The
323
+ // shaping engine decomposes two- or three-part matras into their constituent
324
+ // parts before any repositioning. Matra characters are classified by which
325
+ // consonant in a conjunct they have affinity for and are reordered to the
326
+ // following positions:
327
+ //
328
+ // o Before first half form in the syllable
329
+ // o After subjoined consonants
330
+ // o After post-form consonant
331
+ // o After main consonant (for above marks)
332
+ //
333
+ // IMPLEMENTATION NOTES:
334
+ //
335
+ // The normalize() routine has already decomposed matras for us, so we don't
336
+ // need to worry about that.
337
+
338
+ // 3. Reorder marks to canonical order:
339
+ //
340
+ // Adjacent nukta and halant or nukta and vedic sign are always repositioned
341
+ // if necessary, so that the nukta is first.
342
+ //
343
+ // IMPLEMENTATION NOTES:
344
+ //
345
+ // We don't need to do this: the normalize() routine already did this for us.
346
+
347
+ // Reorder characters
348
+
349
+ for (let i = start; i < base; i++) {
350
+ let info = glyphs[i].shaperInfo;
351
+ info.position = Math.min(POSITIONS.Pre_C, info.position);
352
+ }
353
+
354
+ if (base < end) {
355
+ glyphs[base].shaperInfo.position = POSITIONS.Base_C;
356
+ }
357
+
358
+ // Mark final consonants. A final consonant is one appearing after a matra,
359
+ // like in Khmer.
360
+ for (let i = base + 1; i < end; i++) {
361
+ if (glyphs[i].shaperInfo.category === CATEGORIES.M) {
362
+ for (let j = i + 1; j < end; j++) {
363
+ if (isConsonant(glyphs[j])) {
364
+ glyphs[j].shaperInfo.position = POSITIONS.Final_C;
365
+ break;
366
+ }
367
+ }
368
+ break;
369
+ }
370
+ }
371
+
372
+ // Handle beginning Ra
373
+ if (hasReph) {
374
+ glyphs[start].shaperInfo.position = POSITIONS.Ra_To_Become_Reph;
375
+ }
376
+
377
+ // For old-style Indic script tags, move the first post-base Halant after
378
+ // last consonant.
379
+ //
380
+ // Reports suggest that in some scripts Uniscribe does this only if there
381
+ // is *not* a Halant after last consonant already (eg. Kannada), while it
382
+ // does it unconditionally in other scripts (eg. Malayalam). We don't
383
+ // currently know about other scripts, so we single out Malayalam for now.
384
+ //
385
+ // Kannada test case:
386
+ // U+0C9A,U+0CCD,U+0C9A,U+0CCD
387
+ // With some versions of Lohit Kannada.
388
+ // https://bugs.freedesktop.org/show_bug.cgi?id=59118
389
+ //
390
+ // Malayalam test case:
391
+ // U+0D38,U+0D4D,U+0D31,U+0D4D,U+0D31,U+0D4D
392
+ // With lohit-ttf-20121122/Lohit-Malayalam.ttf
393
+ if (plan.isOldSpec) {
394
+ let disallowDoubleHalants = plan.unicodeScript !== 'Malayalam';
395
+ for (let i = base + 1; i < end; i++) {
396
+ if (glyphs[i].shaperInfo.category === CATEGORIES.H) {
397
+ let j;
398
+ for (j = end - 1; j > i; j--) {
399
+ if (isConsonant(glyphs[j]) || (disallowDoubleHalants && glyphs[j].shaperInfo.category === CATEGORIES.H)) {
400
+ break;
401
+ }
402
+ }
403
+
404
+ if (glyphs[j].shaperInfo.category !== CATEGORIES.H && j > i) {
405
+ // Move Halant to after last consonant.
406
+ let t = glyphs[i];
407
+ glyphs.splice(i, 0, ...glyphs.splice(i + 1, j - i));
408
+ glyphs[j] = t;
409
+ }
410
+
411
+ break;
412
+ }
413
+ }
414
+ }
415
+
416
+ // Attach misc marks to previous char to move with them.
417
+ let lastPos = POSITIONS.Start;
418
+ for (let i = start; i < end; i++) {
419
+ let info = glyphs[i].shaperInfo;
420
+ if (info.category & (JOINER_FLAGS | CATEGORIES.N | CATEGORIES.RS | CATEGORIES.CM | HALANT_OR_COENG_FLAGS & info.category)) {
421
+ info.position = lastPos;
422
+ if (info.category === CATEGORIES.H && info.position === POSITIONS.Pre_M) {
423
+ // Uniscribe doesn't move the Halant with Left Matra.
424
+ // TEST: U+092B,U+093F,U+094DE
425
+ // We follow. This is important for the Sinhala
426
+ // U+0DDA split matra since it decomposes to U+0DD9,U+0DCA
427
+ // where U+0DD9 is a left matra and U+0DCA is the virama.
428
+ // We don't want to move the virama with the left matra.
429
+ // TEST: U+0D9A,U+0DDA
430
+ for (let j = i; j > start; j--) {
431
+ if (glyphs[j - 1].shaperInfo.position !== POSITIONS.Pre_M) {
432
+ info.position = glyphs[j - 1].shaperInfo.position;
433
+ break;
434
+ }
435
+ }
436
+ }
437
+ } else if (info.position !== POSITIONS.SMVD) {
438
+ lastPos = info.position;
439
+ }
440
+ }
441
+
442
+ // For post-base consonants let them own anything before them
443
+ // since the last consonant or matra.
444
+ let last = base;
445
+ for (let i = base + 1; i < end; i++) {
446
+ if (isConsonant(glyphs[i])) {
447
+ for (let j = last + 1; j < i; j++) {
448
+ if (glyphs[j].shaperInfo.position < POSITIONS.SMVD) {
449
+ glyphs[j].shaperInfo.position = glyphs[i].shaperInfo.position;
450
+ }
451
+ }
452
+ last = i;
453
+ } else if (glyphs[i].shaperInfo.category === CATEGORIES.M) {
454
+ last = i;
455
+ }
456
+ }
457
+
458
+ let arr = glyphs.slice(start, end);
459
+ arr.sort((a, b) => a.shaperInfo.position - b.shaperInfo.position);
460
+ glyphs.splice(start, arr.length, ...arr);
461
+
462
+ // Find base again
463
+ for (let i = start; i < end; i++) {
464
+ if (glyphs[i].shaperInfo.position === POSITIONS.Base_C) {
465
+ base = i;
466
+ break;
467
+ }
468
+ }
469
+
470
+ // Setup features now
471
+
472
+ // Reph
473
+ for (let i = start; i < end && glyphs[i].shaperInfo.position === POSITIONS.Ra_To_Become_Reph; i++) {
474
+ glyphs[i].features.rphf = true;
475
+ }
476
+
477
+ // Pre-base
478
+ let blwf = !plan.isOldSpec && indicConfig.blwfMode === 'Pre_And_Post';
479
+ for (let i = start; i < base; i++) {
480
+ glyphs[i].features.half = true;
481
+ if (blwf) {
482
+ glyphs[i].features.blwf = true;
483
+ }
484
+ }
485
+
486
+ // Post-base
487
+ for (let i = base + 1; i < end; i++) {
488
+ glyphs[i].features.abvf = true;
489
+ glyphs[i].features.pstf = true;
490
+ glyphs[i].features.blwf = true;
491
+ }
492
+
493
+ if (plan.isOldSpec && plan.unicodeScript === 'Devanagari') {
494
+ // Old-spec eye-lash Ra needs special handling. From the
495
+ // spec:
496
+ //
497
+ // "The feature 'below-base form' is applied to consonants
498
+ // having below-base forms and following the base consonant.
499
+ // The exception is vattu, which may appear below half forms
500
+ // as well as below the base glyph. The feature 'below-base
501
+ // form' will be applied to all such occurrences of Ra as well."
502
+ //
503
+ // Test case: U+0924,U+094D,U+0930,U+094d,U+0915
504
+ // with Sanskrit 2003 font.
505
+ //
506
+ // However, note that Ra,Halant,ZWJ is the correct way to
507
+ // request eyelash form of Ra, so we wouldbn't inhibit it
508
+ // in that sequence.
509
+ //
510
+ // Test case: U+0924,U+094D,U+0930,U+094d,U+200D,U+0915
511
+ for (let i = start; i + 1 < base; i++) {
512
+ if (glyphs[i].shaperInfo.category === CATEGORIES.Ra &&
513
+ glyphs[i + 1].shaperInfo.category === CATEGORIES.H &&
514
+ (i + 1 === base || glyphs[i + 2].shaperInfo.category === CATEGORIES.ZWJ)
515
+ ) {
516
+ glyphs[i].features.blwf = true;
517
+ glyphs[i + 1].features.blwf = true;
518
+ }
519
+ }
520
+ }
521
+
522
+ let prefLen = 2;
523
+ if (features.pref && base + prefLen < end) {
524
+ // Find a Halant,Ra sequence and mark it for pre-base reordering processing.
525
+ for (let i = base + 1; i + prefLen - 1 < end; i++) {
526
+ let g = [glyphs[i].copy(), glyphs[i + 1].copy()];
527
+ if (wouldSubstitute(g, 'pref')) {
528
+ for (let j = 0; j < prefLen; j++) {
529
+ glyphs[i++].features.pref = true;
530
+ }
531
+
532
+ // Mark the subsequent stuff with 'cfar'. Used in Khmer.
533
+ // Read the feature spec.
534
+ // This allows distinguishing the following cases with MS Khmer fonts:
535
+ // U+1784,U+17D2,U+179A,U+17D2,U+1782
536
+ // U+1784,U+17D2,U+1782,U+17D2,U+179A
537
+ if (features.cfar) {
538
+ for (; i < end; i++) {
539
+ glyphs[i].features.cfar = true;
540
+ }
541
+ }
542
+
543
+ break;
544
+ }
545
+ }
546
+ }
547
+
548
+ // Apply ZWJ/ZWNJ effects
549
+ for (let i = start + 1; i < end; i++) {
550
+ if (isJoiner(glyphs[i])) {
551
+ let nonJoiner = glyphs[i].shaperInfo.category === CATEGORIES.ZWNJ;
552
+ let j = i;
553
+
554
+ do {
555
+ j--;
556
+
557
+ // ZWJ/ZWNJ should disable CJCT. They do that by simply
558
+ // being there, since we don't skip them for the CJCT
559
+ // feature (ie. F_MANUAL_ZWJ)
560
+
561
+ // A ZWNJ disables HALF.
562
+ if (nonJoiner) {
563
+ delete glyphs[j].features.half;
564
+ }
565
+ } while (j > start && !isConsonant(glyphs[j]));
566
+ }
567
+ }
568
+ }
569
+ }
570
+
571
+ function finalReordering(font, glyphs, plan) {
572
+ let indicConfig = plan.indicConfig;
573
+ let features = font._layoutEngine.engine.GSUBProcessor.features;
574
+
575
+ for (let start = 0, end = nextSyllable(glyphs, 0); start < glyphs.length; start = end, end = nextSyllable(glyphs, start)) {
576
+ // 4. Final reordering:
577
+ //
578
+ // After the localized forms and basic shaping forms GSUB features have been
579
+ // applied (see below), the shaping engine performs some final glyph
580
+ // reordering before applying all the remaining font features to the entire
581
+ // cluster.
582
+
583
+ let tryPref = !!features.pref;
584
+
585
+ // Find base again
586
+ let base = start;
587
+ for (; base < end; base++) {
588
+ if (glyphs[base].shaperInfo.position >= POSITIONS.Base_C) {
589
+ if (tryPref && base + 1 < end) {
590
+ for (let i = base + 1; i < end; i++) {
591
+ if (glyphs[i].features.pref) {
592
+ if (!(glyphs[i].substituted && glyphs[i].isLigated && !glyphs[i].isMultiplied)) {
593
+ // Ok, this was a 'pref' candidate but didn't form any.
594
+ // Base is around here...
595
+ base = i;
596
+ while (base < end && isHalantOrCoeng(glyphs[base])) {
597
+ base++;
598
+ }
599
+ glyphs[base].shaperInfo.position = POSITIONS.BASE_C;
600
+ tryPref = false;
601
+ }
602
+ break;
603
+ }
604
+ }
605
+ }
606
+
607
+ // For Malayalam, skip over unformed below- (but NOT post-) forms.
608
+ if (plan.unicodeScript === 'Malayalam') {
609
+ for (let i = base + 1; i < end; i++) {
610
+ while (i < end && isJoiner(glyphs[i])) {
611
+ i++;
612
+ }
613
+
614
+ if (i === end || !isHalantOrCoeng(glyphs[i])) {
615
+ break;
616
+ }
617
+
618
+ i++; // Skip halant.
619
+ while (i < end && isJoiner(glyphs[i])) {
620
+ i++;
621
+ }
622
+
623
+ if (i < end && isConsonant(glyphs[i]) && glyphs[i].shaperInfo.position === POSITIONS.Below_C) {
624
+ base = i;
625
+ glyphs[base].shaperInfo.position = POSITIONS.Base_C;
626
+ }
627
+ }
628
+ }
629
+
630
+ if (start < base && glyphs[base].shaperInfo.position > POSITIONS.Base_C) {
631
+ base--;
632
+ }
633
+ break;
634
+ }
635
+ }
636
+
637
+ if (base === end && start < base && glyphs[base - 1].shaperInfo.category === CATEGORIES.ZWJ) {
638
+ base--;
639
+ }
640
+
641
+ if (base < end) {
642
+ while (start < base && glyphs[base].shaperInfo.category & (CATEGORIES.N | HALANT_OR_COENG_FLAGS)) {
643
+ base--;
644
+ }
645
+ }
646
+
647
+ // o Reorder matras:
648
+ //
649
+ // If a pre-base matra character had been reordered before applying basic
650
+ // features, the glyph can be moved closer to the main consonant based on
651
+ // whether half-forms had been formed. Actual position for the matra is
652
+ // defined as “after last standalone halant glyph, after initial matra
653
+ // position and before the main consonant”. If ZWJ or ZWNJ follow this
654
+ // halant, position is moved after it.
655
+ //
656
+
657
+ if (start + 1 < end && start < base) { // Otherwise there can't be any pre-base matra characters.
658
+ // If we lost track of base, alas, position before last thingy.
659
+ let newPos = base === end ? base - 2 : base - 1;
660
+
661
+ // Malayalam / Tamil do not have "half" forms or explicit virama forms.
662
+ // The glyphs formed by 'half' are Chillus or ligated explicit viramas.
663
+ // We want to position matra after them.
664
+ if (plan.unicodeScript !== 'Malayalam' && plan.unicodeScript !== 'Tamil') {
665
+ while (newPos > start && !(glyphs[newPos].shaperInfo.category & (CATEGORIES.M | HALANT_OR_COENG_FLAGS))) {
666
+ newPos--;
667
+ }
668
+
669
+ // If we found no Halant we are done.
670
+ // Otherwise only proceed if the Halant does
671
+ // not belong to the Matra itself!
672
+ if (isHalantOrCoeng(glyphs[newPos]) && glyphs[newPos].shaperInfo.position !== POSITIONS.Pre_M) {
673
+ // If ZWJ or ZWNJ follow this halant, position is moved after it.
674
+ if (newPos + 1 < end && isJoiner(glyphs[newPos + 1])) {
675
+ newPos++;
676
+ }
677
+ } else {
678
+ newPos = start; // No move.
679
+ }
680
+ }
681
+
682
+ if (start < newPos && glyphs[newPos].shaperInfo.position !== POSITIONS.Pre_M) {
683
+ // Now go see if there's actually any matras...
684
+ for (let i = newPos; i > start; i--) {
685
+ if (glyphs[i - 1].shaperInfo.position === POSITIONS.Pre_M) {
686
+ let oldPos = i - 1;
687
+ if (oldPos < base && base <= newPos) { // Shouldn't actually happen.
688
+ base--;
689
+ }
690
+
691
+ let tmp = glyphs[oldPos];
692
+ glyphs.splice(oldPos, 0, ...glyphs.splice(oldPos + 1, newPos - oldPos));
693
+ glyphs[newPos] = tmp;
694
+
695
+ newPos--;
696
+ }
697
+ }
698
+ }
699
+ }
700
+
701
+ // o Reorder reph:
702
+ //
703
+ // Reph’s original position is always at the beginning of the syllable,
704
+ // (i.e. it is not reordered at the character reordering stage). However,
705
+ // it will be reordered according to the basic-forms shaping results.
706
+ // Possible positions for reph, depending on the script, are; after main,
707
+ // before post-base consonant forms, and after post-base consonant forms.
708
+
709
+ // Two cases:
710
+ //
711
+ // - If repha is encoded as a sequence of characters (Ra,H or Ra,H,ZWJ), then
712
+ // we should only move it if the sequence ligated to the repha form.
713
+ //
714
+ // - If repha is encoded separately and in the logical position, we should only
715
+ // move it if it did NOT ligate. If it ligated, it's probably the font trying
716
+ // to make it work without the reordering.
717
+ if (start + 1 < end &&
718
+ glyphs[start].shaperInfo.position === POSITIONS.Ra_To_Become_Reph &&
719
+ (glyphs[start].shaperInfo.category === CATEGORIES.Repha) !== (glyphs[start].isLigated && !glyphs[start].isMultiplied)
720
+ ) {
721
+ let newRephPos;
722
+ let rephPos = indicConfig.rephPos;
723
+ let found = false;
724
+
725
+ // 1. If reph should be positioned after post-base consonant forms,
726
+ // proceed to step 5.
727
+ if (rephPos !== POSITIONS.After_Post) {
728
+ // 2. If the reph repositioning class is not after post-base: target
729
+ // position is after the first explicit halant glyph between the
730
+ // first post-reph consonant and last main consonant. If ZWJ or ZWNJ
731
+ // are following this halant, position is moved after it. If such
732
+ // position is found, this is the target position. Otherwise,
733
+ // proceed to the next step.
734
+ //
735
+ // Note: in old-implementation fonts, where classifications were
736
+ // fixed in shaping engine, there was no case where reph position
737
+ // will be found on this step.
738
+ newRephPos = start + 1;
739
+ while (newRephPos < base && !isHalantOrCoeng(glyphs[newRephPos])) {
740
+ newRephPos++;
741
+ }
742
+
743
+ if (newRephPos < base && isHalantOrCoeng(glyphs[newRephPos])) {
744
+ // ->If ZWJ or ZWNJ are following this halant, position is moved after it.
745
+ if (newRephPos + 1 < base && isJoiner(glyphs[newRephPos + 1])) {
746
+ newRephPos++;
747
+ }
748
+
749
+ found = true;
750
+ }
751
+
752
+ // 3. If reph should be repositioned after the main consonant: find the
753
+ // first consonant not ligated with main, or find the first
754
+ // consonant that is not a potential pre-base reordering Ra.
755
+ if (!found && rephPos === POSITIONS.After_Main) {
756
+ newRephPos = base;
757
+ while (newRephPos + 1 < end && glyphs[newRephPos + 1].shaperInfo.position <= POSITIONS.After_Main) {
758
+ newRephPos++;
759
+ }
760
+
761
+ found = newRephPos < end;
762
+ }
763
+
764
+ // 4. If reph should be positioned before post-base consonant, find
765
+ // first post-base classified consonant not ligated with main. If no
766
+ // consonant is found, the target position should be before the
767
+ // first matra, syllable modifier sign or vedic sign.
768
+ //
769
+ // This is our take on what step 4 is trying to say (and failing, BADLY).
770
+ if (!found && rephPos === POSITIONS.After_Sub) {
771
+ newRephPos = base;
772
+ while (newRephPos + 1 < end && !(glyphs[newRephPos + 1].shaperInfo.position & (POSITIONS.Post_C | POSITIONS.After_Post | POSITIONS.SMVD))) {
773
+ newRephPos++;
774
+ }
775
+
776
+ found = newRephPos < end;
777
+ }
778
+ }
779
+
780
+ // 5. If no consonant is found in steps 3 or 4, move reph to a position
781
+ // immediately before the first post-base matra, syllable modifier
782
+ // sign or vedic sign that has a reordering class after the intended
783
+ // reph position. For example, if the reordering position for reph
784
+ // is post-main, it will skip above-base matras that also have a
785
+ // post-main position.
786
+ if (!found) {
787
+ // Copied from step 2.
788
+ newRephPos = start + 1;
789
+ while (newRephPos < base && !isHalantOrCoeng(glyphs[newRephPos])) {
790
+ newRephPos++;
791
+ }
792
+
793
+ if (newRephPos < base && isHalantOrCoeng(glyphs[newRephPos])) {
794
+ // ->If ZWJ or ZWNJ are following this halant, position is moved after it.
795
+ if (newRephPos + 1 < base && isJoiner(glyphs[newRephPos + 1])) {
796
+ newRephPos++;
797
+ }
798
+
799
+ found = true;
800
+ }
801
+ }
802
+
803
+ // 6. Otherwise, reorder reph to the end of the syllable.
804
+ if (!found) {
805
+ newRephPos = end - 1;
806
+ while (newRephPos > start && glyphs[newRephPos].shaperInfo.position === POSITIONS.SMVD) {
807
+ newRephPos--;
808
+ }
809
+
810
+ // If the Reph is to be ending up after a Matra,Halant sequence,
811
+ // position it before that Halant so it can interact with the Matra.
812
+ // However, if it's a plain Consonant,Halant we shouldn't do that.
813
+ // Uniscribe doesn't do this.
814
+ // TEST: U+0930,U+094D,U+0915,U+094B,U+094D
815
+ if (isHalantOrCoeng(glyphs[newRephPos])) {
816
+ for (let i = base + 1; i < newRephPos; i++) {
817
+ if (glyphs[i].shaperInfo.category === CATEGORIES.M) {
818
+ newRephPos--;
819
+ }
820
+ }
821
+ }
822
+ }
823
+
824
+ let reph = glyphs[start];
825
+ glyphs.splice(start, 0, ...glyphs.splice(start + 1, newRephPos - start));
826
+ glyphs[newRephPos] = reph;
827
+
828
+ if (start < base && base <= newRephPos) {
829
+ base--;
830
+ }
831
+ }
832
+
833
+ // o Reorder pre-base reordering consonants:
834
+ //
835
+ // If a pre-base reordering consonant is found, reorder it according to
836
+ // the following rules:
837
+ if (tryPref && base + 1 < end) {
838
+ for (let i = base + 1; i < end; i++) {
839
+ if (glyphs[i].features.pref) {
840
+ // 1. Only reorder a glyph produced by substitution during application
841
+ // of the <pref> feature. (Note that a font may shape a Ra consonant with
842
+ // the feature generally but block it in certain contexts.)
843
+
844
+ // Note: We just check that something got substituted. We don't check that
845
+ // the <pref> feature actually did it...
846
+ //
847
+ // Reorder pref only if it ligated.
848
+ if (glyphs[i].isLigated && !glyphs[i].isMultiplied) {
849
+ // 2. Try to find a target position the same way as for pre-base matra.
850
+ // If it is found, reorder pre-base consonant glyph.
851
+ //
852
+ // 3. If position is not found, reorder immediately before main
853
+ // consonant.
854
+ let newPos = base;
855
+
856
+ // Malayalam / Tamil do not have "half" forms or explicit virama forms.
857
+ // The glyphs formed by 'half' are Chillus or ligated explicit viramas.
858
+ // We want to position matra after them.
859
+ if (plan.unicodeScript !== 'Malayalam' && plan.unicodeScript !== 'Tamil') {
860
+ while (newPos > start && !(glyphs[newPos - 1].shaperInfo.category & (CATEGORIES.M | HALANT_OR_COENG_FLAGS))) {
861
+ newPos--;
862
+ }
863
+
864
+ // In Khmer coeng model, a H,Ra can go *after* matras. If it goes after a
865
+ // split matra, it should be reordered to *before* the left part of such matra.
866
+ if (newPos > start && glyphs[newPos - 1].shaperInfo.category === CATEGORIES.M) {
867
+ let oldPos = i;
868
+ for (let j = base + 1; j < oldPos; j++) {
869
+ if (glyphs[j].shaperInfo.category === CATEGORIES.M) {
870
+ newPos--;
871
+ break;
872
+ }
873
+ }
874
+ }
875
+ }
876
+
877
+ if (newPos > start && isHalantOrCoeng(glyphs[newPos - 1])) {
878
+ // -> If ZWJ or ZWNJ follow this halant, position is moved after it.
879
+ if (newPos < end && isJoiner(glyphs[newPos])) {
880
+ newPos++;
881
+ }
882
+ }
883
+
884
+ let oldPos = i;
885
+ let tmp = glyphs[oldPos];
886
+ glyphs.splice(newPos + 1, 0, ...glyphs.splice(newPos, oldPos - newPos));
887
+ glyphs[newPos] = tmp;
888
+
889
+ if (newPos <= base && base < oldPos) {
890
+ base++;
891
+ }
892
+ }
893
+
894
+ break;
895
+ }
896
+ }
897
+ }
898
+
899
+ // Apply 'init' to the Left Matra if it's a word start.
900
+ if (glyphs[start].shaperInfo.position === POSITIONS.Pre_M && (!start || !/Cf|Mn/.test(getCategory(glyphs[start - 1].codePoints[0])))) {
901
+ glyphs[start].features.init = true;
902
+ }
903
+ }
904
+ }
905
+
906
+ function nextSyllable(glyphs, start) {
907
+ if (start >= glyphs.length) return start;
908
+ let syllable = glyphs[start].shaperInfo.syllable;
909
+ while (++start < glyphs.length && glyphs[start].shaperInfo.syllable === syllable);
910
+ return start;
911
+ }
node_modules/fontkit/src/opentype/shapers/UniversalShaper.js ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import DefaultShaper from './DefaultShaper';
2
+ import StateMachine from 'dfa';
3
+ import UnicodeTrie from 'unicode-trie';
4
+ import GlyphInfo from '../GlyphInfo';
5
+ import useData from './use.json';
6
+ import { decodeBase64 } from '../../utils';
7
+
8
+ const {categories, decompositions} = useData;
9
+ const trie = new UnicodeTrie(decodeBase64(require('fs').readFileSync(__dirname + '/use.trie', 'base64')));
10
+ const stateMachine = new StateMachine(useData);
11
+
12
+ /**
13
+ * This shaper is an implementation of the Universal Shaping Engine, which
14
+ * uses Unicode data to shape a number of scripts without a dedicated shaping engine.
15
+ * See https://www.microsoft.com/typography/OpenTypeDev/USE/intro.htm.
16
+ */
17
+ export default class UniversalShaper extends DefaultShaper {
18
+ static zeroMarkWidths = 'BEFORE_GPOS';
19
+ static planFeatures(plan) {
20
+ plan.addStage(setupSyllables);
21
+
22
+ // Default glyph pre-processing group
23
+ plan.addStage(['locl', 'ccmp', 'nukt', 'akhn']);
24
+
25
+ // Reordering group
26
+ plan.addStage(clearSubstitutionFlags);
27
+ plan.addStage(['rphf'], false);
28
+ plan.addStage(recordRphf);
29
+ plan.addStage(clearSubstitutionFlags);
30
+ plan.addStage(['pref']);
31
+ plan.addStage(recordPref);
32
+
33
+ // Orthographic unit shaping group
34
+ plan.addStage(['rkrf', 'abvf', 'blwf', 'half', 'pstf', 'vatu', 'cjct']);
35
+ plan.addStage(reorder);
36
+
37
+ // Topographical features
38
+ // Scripts that need this are handled by the Arabic shaper, not implemented here for now.
39
+ // plan.addStage(['isol', 'init', 'medi', 'fina', 'med2', 'fin2', 'fin3'], false);
40
+
41
+ // Standard topographic presentation and positional feature application
42
+ plan.addStage(['abvs', 'blws', 'pres', 'psts', 'dist', 'abvm', 'blwm']);
43
+ }
44
+
45
+ static assignFeatures(plan, glyphs) {
46
+ // Decompose split vowels
47
+ // TODO: do this in a more general unicode normalizer
48
+ for (let i = glyphs.length - 1; i >= 0; i--) {
49
+ let codepoint = glyphs[i].codePoints[0];
50
+ if (decompositions[codepoint]) {
51
+ let decomposed = decompositions[codepoint].map(c => {
52
+ let g = plan.font.glyphForCodePoint(c);
53
+ return new GlyphInfo(plan.font, g.id, [c], glyphs[i].features);
54
+ });
55
+
56
+ glyphs.splice(i, 1, ...decomposed);
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ function useCategory(glyph) {
63
+ return trie.get(glyph.codePoints[0]);
64
+ }
65
+
66
+ class USEInfo {
67
+ constructor(category, syllableType, syllable) {
68
+ this.category = category;
69
+ this.syllableType = syllableType;
70
+ this.syllable = syllable;
71
+ }
72
+ }
73
+
74
+ function setupSyllables(font, glyphs) {
75
+ let syllable = 0;
76
+ for (let [start, end, tags] of stateMachine.match(glyphs.map(useCategory))) {
77
+ ++syllable;
78
+
79
+ // Create shaper info
80
+ for (let i = start; i <= end; i++) {
81
+ glyphs[i].shaperInfo = new USEInfo(categories[useCategory(glyphs[i])], tags[0], syllable);
82
+ }
83
+
84
+ // Assign rphf feature
85
+ let limit = glyphs[start].shaperInfo.category === 'R' ? 1 : Math.min(3, end - start);
86
+ for (let i = start; i < start + limit; i++) {
87
+ glyphs[i].features.rphf = true;
88
+ }
89
+ }
90
+ }
91
+
92
+ function clearSubstitutionFlags(font, glyphs) {
93
+ for (let glyph of glyphs) {
94
+ glyph.substituted = false;
95
+ }
96
+ }
97
+
98
+ function recordRphf(font, glyphs) {
99
+ for (let glyph of glyphs) {
100
+ if (glyph.substituted && glyph.features.rphf) {
101
+ // Mark a substituted repha.
102
+ glyph.shaperInfo.category = 'R';
103
+ }
104
+ }
105
+ }
106
+
107
+ function recordPref(font, glyphs) {
108
+ for (let glyph of glyphs) {
109
+ if (glyph.substituted) {
110
+ // Mark a substituted pref as VPre, as they behave the same way.
111
+ glyph.shaperInfo.category = 'VPre';
112
+ }
113
+ }
114
+ }
115
+
116
+ function reorder(font, glyphs) {
117
+ let dottedCircle = font.glyphForCodePoint(0x25cc).id;
118
+
119
+ for (let start = 0, end = nextSyllable(glyphs, 0); start < glyphs.length; start = end, end = nextSyllable(glyphs, start)) {
120
+ let i, j;
121
+ let info = glyphs[start].shaperInfo;
122
+ let type = info.syllableType;
123
+
124
+ // Only a few syllable types need reordering.
125
+ if (type !== 'virama_terminated_cluster' && type !== 'standard_cluster' && type !== 'broken_cluster') {
126
+ continue;
127
+ }
128
+
129
+ // Insert a dotted circle glyph in broken clusters.
130
+ if (type === 'broken_cluster' && dottedCircle) {
131
+ let g = new GlyphInfo(font, dottedCircle, [0x25cc]);
132
+ g.shaperInfo = info;
133
+
134
+ // Insert after possible Repha.
135
+ for (i = start; i < end && glyphs[i].shaperInfo.category === 'R'; i++);
136
+ glyphs.splice(++i, 0, g);
137
+ end++;
138
+ }
139
+
140
+ // Move things forward.
141
+ if (info.category === 'R' && end - start > 1) {
142
+ // Got a repha. Reorder it to after first base, before first halant.
143
+ for (i = start + 1; i < end; i++) {
144
+ info = glyphs[i].shaperInfo;
145
+ if (isBase(info) || isHalant(glyphs[i])) {
146
+ // If we hit a halant, move before it; otherwise it's a base: move to it's
147
+ // place, and shift things in between backward.
148
+ if (isHalant(glyphs[i])) {
149
+ i--;
150
+ }
151
+
152
+ glyphs.splice(start, 0, ...glyphs.splice(start + 1, i - start), glyphs[i]);
153
+ break;
154
+ }
155
+ }
156
+ }
157
+
158
+ // Move things back.
159
+ for (i = start, j = end; i < end; i++) {
160
+ info = glyphs[i].shaperInfo;
161
+ if (isBase(info) || isHalant(glyphs[i])) {
162
+ // If we hit a halant, move after it; otherwise it's a base: move to it's
163
+ // place, and shift things in between backward.
164
+ j = isHalant(glyphs[i]) ? i + 1 : i;
165
+ } else if ((info.category === 'VPre' || info.category === 'VMPre') && j < i) {
166
+ glyphs.splice(j, 1, glyphs[i], ...glyphs.splice(j, i - j));
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
+ function nextSyllable(glyphs, start) {
173
+ if (start >= glyphs.length) return start;
174
+ let syllable = glyphs[start].shaperInfo.syllable;
175
+ while (++start < glyphs.length && glyphs[start].shaperInfo.syllable === syllable);
176
+ return start;
177
+ }
178
+
179
+ function isHalant(glyph) {
180
+ return glyph.shaperInfo.category === 'H' && !glyph.isLigated;
181
+ }
182
+
183
+ function isBase(info) {
184
+ return info.category === 'B' || info.category === 'GB';
185
+ }
node_modules/fontkit/src/opentype/shapers/data.trie ADDED
Binary file (526 Bytes). View file
 
node_modules/fontkit/src/opentype/shapers/gen-indic.js ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import codepoints from 'codepoints';
2
+ import fs from 'fs';
3
+ import UnicodeTrieBuilder from 'unicode-trie/builder.js';
4
+ import dfa from 'dfa/compile.js';
5
+ import { CATEGORIES, POSITIONS, CONSONANT_FLAGS } from './indic-data.js';
6
+
7
+ const compile = dfa.default;
8
+
9
+ const CATEGORY_MAP = {
10
+ Avagraha: 'Symbol',
11
+ Bindu: 'SM',
12
+ Brahmi_Joining_Number: 'Placeholder',
13
+ Cantillation_Mark: 'A',
14
+ Consonant: 'C',
15
+ Consonant_Dead: 'C',
16
+ Consonant_Final: 'CM',
17
+ Consonant_Head_Letter: 'C',
18
+ Consonant_Killer: 'M',
19
+ Consonant_Medial: 'CM',
20
+ Consonant_Placeholder: 'Placeholder',
21
+ Consonant_Preceding_Repha: 'Repha',
22
+ Consonant_Prefixed: 'X',
23
+ Consonant_Subjoined: 'CM',
24
+ Consonant_Succeeding_Repha: 'N',
25
+ Consonant_With_Stacker: 'Repha',
26
+ Gemination_Mark: 'SM',
27
+ Invisible_Stacker: 'Coeng',
28
+ Joiner: 'ZWJ',
29
+ Modifying_Letter: 'X',
30
+ Non_Joiner: 'ZWNJ',
31
+ Nukta: 'N',
32
+ Number: 'Placeholder',
33
+ Number_Joiner: 'Placeholder',
34
+ Pure_Killer: 'M',
35
+ Register_Shifter: 'RS',
36
+ Syllable_Modifier: 'M',
37
+ Tone_Letter: 'X',
38
+ Tone_Mark: 'N',
39
+ Virama: 'H',
40
+ Visarga: 'SM',
41
+ Vowel: 'V',
42
+ Vowel_Dependent: 'M',
43
+ Vowel_Independent: 'V'
44
+ };
45
+
46
+ const OVERRIDES = {
47
+ 0x0953: 'SM',
48
+ 0x0954: 'SM',
49
+ 0x0A72: 'C',
50
+ 0x0A73: 'C',
51
+ 0x1CF5: 'C',
52
+ 0x1CF6: 'C',
53
+ 0x1CE2: 'A',
54
+ 0x1CE3: 'A',
55
+ 0x1CE4: 'A',
56
+ 0x1CE5: 'A',
57
+ 0x1CE6: 'A',
58
+ 0x1CE7: 'A',
59
+ 0x1CE8: 'A',
60
+ 0x1CED: 'A',
61
+ 0xA8F2: 'Symbol',
62
+ 0xA8F3: 'Symbol',
63
+ 0xA8F4: 'Symbol',
64
+ 0xA8F5: 'Symbol',
65
+ 0xA8F6: 'Symbol',
66
+ 0xA8F7: 'Symbol',
67
+ 0x1CE9: 'Symbol',
68
+ 0x1CEA: 'Symbol',
69
+ 0x1CEB: 'Symbol',
70
+ 0x1CEC: 'Symbol',
71
+ 0x1CEE: 'Symbol',
72
+ 0x1CEF: 'Symbol',
73
+ 0x1CF0: 'Symbol',
74
+ 0x1CF1: 'Symbol',
75
+ 0x17C6: 'N',
76
+ 0x2010: 'Placeholder',
77
+ 0x2011: 'Placeholder',
78
+ 0x25CC: 'Dotted_Circle',
79
+
80
+ // Ra
81
+ 0x0930: 'Ra', // Devanagari
82
+ 0x09B0: 'Ra', // Bengali
83
+ 0x09F0: 'Ra', // Bengali
84
+ 0x0A30: 'Ra', // Gurmukhi - No Reph
85
+ 0x0AB0: 'Ra', // Gujarati
86
+ 0x0B30: 'Ra', // Oriya
87
+ 0x0BB0: 'Ra', // Tamil - No Reph
88
+ 0x0C30: 'Ra', // Telugu - Reph formed only with ZWJ
89
+ 0x0CB0: 'Ra', // Kannada
90
+ 0x0D30: 'Ra', // Malayalam - No Reph, Logical Repha
91
+ 0x0DBB: 'Ra', // Sinhala - Reph formed only with ZWJ
92
+ 0x179A: 'Ra', // Khmer - No Reph, Visual Repha
93
+ };
94
+
95
+ const POSITION_MAP = {
96
+ Left: 'Pre_C',
97
+ Top: 'Above_C',
98
+ Bottom: 'Below_C',
99
+ Right: 'Post_C',
100
+
101
+ // These should resolve to the position of the last part of the split sequence.
102
+ Bottom_And_Right: 'Post_C',
103
+ Left_And_Right: 'Post_C',
104
+ Top_And_Bottom: 'Below_C',
105
+ Top_And_Bottom_And_Right: 'Post_C',
106
+ Top_And_Left: 'Above_C',
107
+ Top_And_Left_And_Right: 'Post_C',
108
+ Top_And_Right: 'Post_C',
109
+
110
+ Overstruck: 'After_Main',
111
+ Visual_Order_Left: 'Pre_M'
112
+ };
113
+
114
+ function matraPosition(c, pos) {
115
+ switch (pos) {
116
+ case 'Pre_C':
117
+ return 'Pre_M';
118
+
119
+ case 'Post_C':
120
+ switch (c.block) {
121
+ case 'Devanagari': return 'After_Sub';
122
+ case 'Bengali': return 'After_Post';
123
+ case 'Gurmukhi': return 'After_Post';
124
+ case 'Gujarati': return 'After_Post';
125
+ case 'Oriya': return 'After_Post';
126
+ case 'Tamil': return 'After_Post';
127
+ case 'Telugu': return c.code <= 0x0C42 ? 'Before_Sub' : 'After_Sub';
128
+ case 'Kannada': return c.code < 0x0CC3 || c.code > 0xCD6 ? 'Before_Sub' : 'After_Sub';
129
+ case 'Malayalam': return 'After_Post';
130
+ case 'Sinhala': return 'After_Sub';
131
+ case 'Khmer': return 'After_Post';
132
+ default: return 'After_Sub';
133
+ }
134
+
135
+ case 'Above_C':
136
+ switch (c.block) {
137
+ case 'Devanagari': return 'After_Sub';
138
+ case 'Gurmukhi': return 'After_Post'; // Deviate from spec
139
+ case 'Gujarati': return 'After_Sub';
140
+ case 'Oriya': return 'After_Main';
141
+ case 'Tamil': return 'After_Sub';
142
+ case 'Telugu': return 'Before_Sub';
143
+ case 'Kannada': return 'Before_Sub';
144
+ case 'Sinhala': return 'After_Sub';
145
+ case 'Khmer': return 'After_Post';
146
+ default: return 'After_Sub';
147
+ }
148
+
149
+ case 'Below_C':
150
+ switch (c.block) {
151
+ case 'Devanagari': return 'After_Sub';
152
+ case 'Bengali': return 'After_Sub';
153
+ case 'Gurmukhi': return 'After_Post';
154
+ case 'Gujarati': return 'After_Post';
155
+ case 'Oriya': return 'After_Sub';
156
+ case 'Tamil': return 'After_Post';
157
+ case 'Telugu': return 'Before_Sub';
158
+ case 'Kannada': return 'Before_Sub';
159
+ case 'Malayalam': return 'After_Post';
160
+ case 'Sinhala': return 'After_Sub';
161
+ case 'Khmer': return 'After_Post';
162
+ default: return 'After_Sub';
163
+ }
164
+
165
+ default:
166
+ return pos;
167
+ }
168
+ }
169
+
170
+ function getPosition(codepoint, category) {
171
+ let position = POSITION_MAP[codepoint.indicPositionalCategory] || 'End';
172
+
173
+ if (CATEGORIES[category] & CONSONANT_FLAGS) {
174
+ position = 'Base_C';
175
+ } else if (category === 'M') {
176
+ position = matraPosition(codepoint, position);
177
+ } else if (category === 'SM' || category === 'VD' || category === 'A' || category === 'Symbol') {
178
+ position = 'SMVD';
179
+ }
180
+
181
+ // Oriya Bindu is Before_Sub in the spec.
182
+ if (codepoint.code === 0x0B01) {
183
+ position = 'Before_Sub';
184
+ }
185
+
186
+ return Math.log2(POSITIONS[position]);
187
+ }
188
+
189
+ let symbols = {};
190
+ for (let c in CATEGORIES) {
191
+ symbols[c] = Math.log2(CATEGORIES[c]);
192
+ }
193
+
194
+ let trie = new UnicodeTrieBuilder;
195
+ for (let i = 0; i < codepoints.length; i++) {
196
+ let codepoint = codepoints[i];
197
+ if (codepoint) {
198
+ let category = OVERRIDES[codepoint.code] || CATEGORY_MAP[codepoint.indicSyllabicCategory] || 'X';
199
+ let position = getPosition(codepoint, category);
200
+
201
+ trie.set(codepoint.code, (symbols[category] << 8) | position);
202
+ }
203
+ }
204
+
205
+ fs.writeFileSync(new URL('indic.trie', import.meta.url), trie.toBuffer());
206
+
207
+ let stateMachine = compile(fs.readFileSync(new URL('indic.machine', import.meta.url), 'utf8'), symbols);
208
+ fs.writeFileSync(new URL('indic.json', import.meta.url), JSON.stringify(stateMachine));
node_modules/fontkit/src/opentype/shapers/gen-use.js ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import codepoints from 'codepoints';
2
+ import fs from 'fs';
3
+ import UnicodeTrieBuilder from 'unicode-trie/builder.js';
4
+ import dfa from 'dfa/compile.js';
5
+
6
+ const compile = dfa.default;
7
+
8
+ const CATEGORIES = {
9
+ B: [
10
+ {UISC: 'Number'},
11
+ {UISC: 'Avagraha', UGC: 'Lo'},
12
+ {UISC: 'Bindu', UGC: 'Lo'},
13
+ {UISC: 'Consonant'},
14
+ {UISC: 'Consonant_Final', UGC: 'Lo'},
15
+ {UISC: 'Consonant_Head_Letter'},
16
+ {UISC: 'Consonant_Medial', UGC: 'Lo'},
17
+ {UISC: 'Consonant_Subjoined', UGC: 'Lo'},
18
+ {UISC: 'Tone_Letter'},
19
+ {UISC: 'Vowel', UGC: 'Lo'},
20
+ {UISC: 'Vowel_Independent'},
21
+ {UISC: 'Vowel_Dependent', UGC: 'Lo'}
22
+ ],
23
+ CGJ: [0x034f],
24
+ CM: [
25
+ 'Nukta',
26
+ 'Gemination_Mark',
27
+ 'Consonant_Killer'
28
+ ],
29
+ CS: [
30
+ 'Consonant_With_Stacker'
31
+ ],
32
+ F: [
33
+ {UISC: 'Consonant_Final', UGC: {not: 'Lo'}},
34
+ {UISC: 'Consonant_Succeeding_Repha'}
35
+ ],
36
+ FM: [
37
+ 'Syllable_Modifier'
38
+ ],
39
+ GB: [
40
+ 'Consonant_Placeholder',
41
+ 0x2015,
42
+ 0x2022,
43
+ 0x25fb,
44
+ 0x25fc,
45
+ 0x25fd,
46
+ 0x25fe
47
+ ],
48
+ H: [
49
+ 'Virama',
50
+ 'Invisible_Stacker'
51
+ ],
52
+ HN: [
53
+ 'Number_Joiner'
54
+ ],
55
+ IND: [
56
+ 'Consonant_Dead',
57
+ 'Modifying_Letter',
58
+ {UGC: 'Po', U: {not: [0x104e, 0x2022]}}
59
+ ],
60
+ M: [
61
+ {UISC: 'Consonant_Medial', UGC: {not: 'Lo'}}
62
+ ],
63
+ N: [
64
+ 'Brahmi_Joining_Number'
65
+ ],
66
+ R: [
67
+ 'Consonant_Preceding_Repha',
68
+ 'Consonant_Prefixed'
69
+ ],
70
+ Rsv: [
71
+ {UGC: 'Cn'} // TODO
72
+ ],
73
+ S: [
74
+ {UGC: 'So', U: {not: 0x25cc}},
75
+ {UGC: 'Sc'}
76
+ ],
77
+ SM: [
78
+ 0x1b6b,
79
+ 0x1b6c,
80
+ 0x1b6d,
81
+ 0x1b6e,
82
+ 0x1b6f,
83
+ 0x1b70,
84
+ 0x1b71,
85
+ 0x1b72,
86
+ 0x1b73
87
+ ],
88
+ SUB: [
89
+ {UISC: 'Consonant_Subjoined', UGC: {not: 'Lo'}}
90
+ ],
91
+ V: [
92
+ {UISC: 'Vowel', UGC: {not: 'Lo'}},
93
+ {UISC: 'Vowel_Dependent', UGC: {not: 'Lo'}},
94
+ {UISC: 'Pure_Killer'}
95
+ ],
96
+ VM: [
97
+ {UISC: 'Bindu', UGC: {not: 'Lo'}},
98
+ 'Tone_Mark',
99
+ 'Cantillation_Mark',
100
+ 'Register_Shifter',
101
+ 'Visarga'
102
+ ],
103
+ VS: [
104
+ 0xfe00, 0xfe01, 0xfe02, 0xfe03, 0xfe04, 0xfe05, 0xfe06, 0xfe07,
105
+ 0xfe08, 0xfe09, 0xfe0a, 0xfe0b, 0xfe0c, 0xfe0d, 0xfe0e, 0xfe0f
106
+ ],
107
+ WJ: [0x2060],
108
+ ZWJ: [
109
+ 'Joiner'
110
+ ],
111
+ ZWNJ: [
112
+ 'Non_Joiner'
113
+ ],
114
+ O: [
115
+ 'Other'
116
+ ]
117
+ };
118
+
119
+ const USE_POSITIONS = {
120
+ F: {
121
+ Abv: ['Top'],
122
+ Blw: ['Bottom'],
123
+ Pst: ['Right'],
124
+ },
125
+ M: {
126
+ Abv: ['Top'],
127
+ Blw: ['Bottom'],
128
+ Pst: ['Right'],
129
+ Pre: ['Left'],
130
+ },
131
+ CM: {
132
+ Abv: ['Top'],
133
+ Blw: ['Bottom'],
134
+ },
135
+ V: {
136
+ Abv: ['Top', 'Top_And_Bottom', 'Top_And_Bottom_And_Right', 'Top_And_Right'],
137
+ Blw: ['Bottom', 'Overstruck', 'Bottom_And_Right'],
138
+ Pst: ['Right'],
139
+ Pre: ['Left', 'Top_And_Left', 'Top_And_Left_And_Right', 'Left_And_Right'],
140
+ },
141
+ VM: {
142
+ Abv: ['Top'],
143
+ Blw: ['Bottom', 'Overstruck'],
144
+ Pst: ['Right'],
145
+ Pre: ['Left'],
146
+ },
147
+ SM: {
148
+ Abv: ['Top'],
149
+ Blw: ['Bottom'],
150
+ }
151
+ };
152
+
153
+ const UISC_OVERRIDE = {
154
+ 0x17dd: 'Vowel_Dependent',
155
+ 0x1ce2: 'Cantillation_Mark',
156
+ 0x1ce3: 'Cantillation_Mark',
157
+ 0x1ce4: 'Cantillation_Mark',
158
+ 0x1ce5: 'Cantillation_Mark',
159
+ 0x1ce6: 'Cantillation_Mark',
160
+ 0x1ce7: 'Cantillation_Mark',
161
+ 0x1ce8: 'Cantillation_Mark',
162
+ 0x1ced: 'Tone_Mark'
163
+ };
164
+
165
+ const UIPC_OVERRIDE = {
166
+ 0x1b6c: 'Bottom',
167
+ 0x953: 'Not_Applicable',
168
+ 0x954: 'Not_Applicable',
169
+ 0x103c: 'Left',
170
+ 0xa926: 'Top',
171
+ 0xa927: 'Top',
172
+ 0xa928: 'Top',
173
+ 0xa929: 'Top',
174
+ 0xa92a: 'Top',
175
+ 0x111ca: 'Bottom',
176
+ 0x11300: 'Top',
177
+ 0x1133c: 'Bottom',
178
+ 0x1171e: 'Left',
179
+ 0x1cf2: 'Right',
180
+ 0x1cf3: 'Right',
181
+ 0x1cf8: 'Top',
182
+ 0x1cf9: 'Top'
183
+ };
184
+
185
+ function check(pattern, value) {
186
+ if (typeof pattern === 'object' && pattern.not) {
187
+ if (Array.isArray(pattern.not)) {
188
+ return pattern.not.indexOf(value) === -1;
189
+ } else {
190
+ return value !== pattern.not;
191
+ }
192
+ }
193
+
194
+ return value === pattern;
195
+ }
196
+
197
+ function matches(pattern, code) {
198
+ if (typeof pattern === 'number') {
199
+ pattern = {U: pattern};
200
+ } else if (typeof pattern === 'string') {
201
+ pattern = {UISC: pattern};
202
+ }
203
+
204
+ for (let key in pattern) {
205
+ if (!check(pattern[key], code[key])) {
206
+ return false;
207
+ }
208
+ }
209
+
210
+ return true;
211
+ }
212
+
213
+ function getUISC(code) {
214
+ return UISC_OVERRIDE[code.code] || code.indicSyllabicCategory || 'Other';
215
+ }
216
+
217
+ function getUIPC(code) {
218
+ return UIPC_OVERRIDE[code.code] || code.indicPositionalCategory;
219
+ }
220
+
221
+ function getPositionalCategory(code, USE) {
222
+ let UIPC = getUIPC(code);
223
+ let pos = USE_POSITIONS[USE];
224
+ if (pos) {
225
+ for (let key in pos) {
226
+ if (pos[key].indexOf(UIPC) !== -1) {
227
+ return USE + key;
228
+ }
229
+ }
230
+ }
231
+
232
+ return USE;
233
+ }
234
+
235
+ function getCategory(code) {
236
+ for (let category in CATEGORIES) {
237
+ for (let pattern of CATEGORIES[category]) {
238
+ if (matches(pattern, {UISC: getUISC(code), UGC: code.category, U: code.code})) {
239
+ return getPositionalCategory(code, category);
240
+ }
241
+ }
242
+ }
243
+
244
+ return null;
245
+ }
246
+
247
+ let trie = new UnicodeTrieBuilder;
248
+ let symbols = {};
249
+ let numSymbols = 0;
250
+ let decompositions = {};
251
+ for (let i = 0; i < codepoints.length; i++) {
252
+ let codepoint = codepoints[i];
253
+ if (codepoint) {
254
+ let category = getCategory(codepoint);
255
+ if (!(category in symbols)) {
256
+ symbols[category] = numSymbols++;
257
+ }
258
+
259
+ trie.set(codepoint.code, symbols[category]);
260
+
261
+ if (codepoint.indicSyllabicCategory === 'Vowel_Dependent' && codepoint.decomposition.length > 0) {
262
+ decompositions[codepoint.code] = decompose(codepoint.code);
263
+ }
264
+ }
265
+ }
266
+
267
+ function decompose(code) {
268
+ let decomposition = [];
269
+ let codepoint = codepoints[code];
270
+ for (let c of codepoint.decomposition) {
271
+ let codes = decompose(c);
272
+ codes = codes.length > 0 ? codes : [c];
273
+ decomposition.push(...codes);
274
+ }
275
+
276
+ return decomposition;
277
+ }
278
+
279
+ fs.writeFileSync(new URL('use.trie', import.meta.url), trie.toBuffer());
280
+
281
+ let stateMachine = compile(fs.readFileSync(new URL('use.machine', import.meta.url), 'utf8'), symbols);
282
+ let json = Object.assign({
283
+ categories: Object.keys(symbols),
284
+ decompositions: decompositions
285
+ }, stateMachine);
286
+
287
+ fs.writeFileSync(new URL('use.json', import.meta.url), JSON.stringify(json));
node_modules/fontkit/src/opentype/shapers/generate-data.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // This script generates a UnicodeTrie containing shaping data derived
3
+ // from Unicode properties (currently just for the Arabic shaper).
4
+ //
5
+ import codepoints from 'codepoints';
6
+ import fs from 'fs';
7
+ import UnicodeTrieBuilder from 'unicode-trie/builder.js';
8
+
9
+ let ShapingClasses = {
10
+ Non_Joining: 0,
11
+ Left_Joining: 1,
12
+ Right_Joining: 2,
13
+ Dual_Joining: 3,
14
+ Join_Causing: 3,
15
+ ALAPH: 4,
16
+ 'DALATH RISH': 5,
17
+ Transparent: 6
18
+ };
19
+
20
+ let trie = new UnicodeTrieBuilder;
21
+ for (let i = 0; i < codepoints.length; i++) {
22
+ let codepoint = codepoints[i];
23
+ if (codepoint) {
24
+ if (codepoint.joiningGroup === 'ALAPH' || codepoint.joiningGroup === 'DALATH RISH') {
25
+ trie.set(codepoint.code, ShapingClasses[codepoint.joiningGroup] + 1);
26
+
27
+ } else if (codepoint.joiningType) {
28
+ trie.set(codepoint.code, ShapingClasses[codepoint.joiningType] + 1);
29
+ }
30
+ }
31
+ }
32
+
33
+ fs.writeFileSync(new URL('data.trie', import.meta.url), trie.toBuffer());
node_modules/fontkit/src/opentype/shapers/index.js ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import DefaultShaper from './DefaultShaper';
2
+ import ArabicShaper from './ArabicShaper';
3
+ import HangulShaper from './HangulShaper';
4
+ import IndicShaper from './IndicShaper';
5
+ import UniversalShaper from './UniversalShaper';
6
+
7
+ const SHAPERS = {
8
+ arab: ArabicShaper, // Arabic
9
+ mong: ArabicShaper, // Mongolian
10
+ syrc: ArabicShaper, // Syriac
11
+ 'nko ': ArabicShaper, // N'Ko
12
+ phag: ArabicShaper, // Phags Pa
13
+ mand: ArabicShaper, // Mandaic
14
+ mani: ArabicShaper, // Manichaean
15
+ phlp: ArabicShaper, // Psalter Pahlavi
16
+
17
+ hang: HangulShaper, // Hangul
18
+
19
+ bng2: IndicShaper, // Bengali
20
+ beng: IndicShaper, // Bengali
21
+ dev2: IndicShaper, // Devanagari
22
+ deva: IndicShaper, // Devanagari
23
+ gjr2: IndicShaper, // Gujarati
24
+ gujr: IndicShaper, // Gujarati
25
+ guru: IndicShaper, // Gurmukhi
26
+ gur2: IndicShaper, // Gurmukhi
27
+ knda: IndicShaper, // Kannada
28
+ knd2: IndicShaper, // Kannada
29
+ mlm2: IndicShaper, // Malayalam
30
+ mlym: IndicShaper, // Malayalam
31
+ ory2: IndicShaper, // Oriya
32
+ orya: IndicShaper, // Oriya
33
+ taml: IndicShaper, // Tamil
34
+ tml2: IndicShaper, // Tamil
35
+ telu: IndicShaper, // Telugu
36
+ tel2: IndicShaper, // Telugu
37
+ khmr: IndicShaper, // Khmer
38
+
39
+ bali: UniversalShaper, // Balinese
40
+ batk: UniversalShaper, // Batak
41
+ brah: UniversalShaper, // Brahmi
42
+ bugi: UniversalShaper, // Buginese
43
+ buhd: UniversalShaper, // Buhid
44
+ cakm: UniversalShaper, // Chakma
45
+ cham: UniversalShaper, // Cham
46
+ dupl: UniversalShaper, // Duployan
47
+ egyp: UniversalShaper, // Egyptian Hieroglyphs
48
+ gran: UniversalShaper, // Grantha
49
+ hano: UniversalShaper, // Hanunoo
50
+ java: UniversalShaper, // Javanese
51
+ kthi: UniversalShaper, // Kaithi
52
+ kali: UniversalShaper, // Kayah Li
53
+ khar: UniversalShaper, // Kharoshthi
54
+ khoj: UniversalShaper, // Khojki
55
+ sind: UniversalShaper, // Khudawadi
56
+ lepc: UniversalShaper, // Lepcha
57
+ limb: UniversalShaper, // Limbu
58
+ mahj: UniversalShaper, // Mahajani
59
+ // mand: UniversalShaper, // Mandaic
60
+ // mani: UniversalShaper, // Manichaean
61
+ mtei: UniversalShaper, // Meitei Mayek
62
+ modi: UniversalShaper, // Modi
63
+ // mong: UniversalShaper, // Mongolian
64
+ // 'nko ': UniversalShaper, // N’Ko
65
+ hmng: UniversalShaper, // Pahawh Hmong
66
+ // phag: UniversalShaper, // Phags-pa
67
+ // phlp: UniversalShaper, // Psalter Pahlavi
68
+ rjng: UniversalShaper, // Rejang
69
+ saur: UniversalShaper, // Saurashtra
70
+ shrd: UniversalShaper, // Sharada
71
+ sidd: UniversalShaper, // Siddham
72
+ sinh: IndicShaper, // Sinhala
73
+ sund: UniversalShaper, // Sundanese
74
+ sylo: UniversalShaper, // Syloti Nagri
75
+ tglg: UniversalShaper, // Tagalog
76
+ tagb: UniversalShaper, // Tagbanwa
77
+ tale: UniversalShaper, // Tai Le
78
+ lana: UniversalShaper, // Tai Tham
79
+ tavt: UniversalShaper, // Tai Viet
80
+ takr: UniversalShaper, // Takri
81
+ tibt: UniversalShaper, // Tibetan
82
+ tfng: UniversalShaper, // Tifinagh
83
+ tirh: UniversalShaper, // Tirhuta
84
+
85
+ latn: DefaultShaper, // Latin
86
+ DFLT: DefaultShaper // Default
87
+ };
88
+
89
+ export function choose(script) {
90
+ if (!Array.isArray(script)) {
91
+ script = [script];
92
+ }
93
+
94
+ for (let s of script) {
95
+ let shaper = SHAPERS[s];
96
+ if (shaper) {
97
+ return shaper;
98
+ }
99
+ }
100
+
101
+ return DefaultShaper;
102
+ }
node_modules/fontkit/src/opentype/shapers/indic-data.js ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Cateories used in the OpenType spec:
2
+ // https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx
3
+ export const CATEGORIES = {
4
+ X: 1 << 0,
5
+ C: 1 << 1,
6
+ V: 1 << 2,
7
+ N: 1 << 3,
8
+ H: 1 << 4,
9
+ ZWNJ: 1 << 5,
10
+ ZWJ: 1 << 6,
11
+ M: 1 << 7,
12
+ SM: 1 << 8,
13
+ VD: 1 << 9,
14
+ A: 1 << 10,
15
+ Placeholder: 1 << 11,
16
+ Dotted_Circle: 1 << 12,
17
+ RS: 1 << 13, // Register Shifter, used in Khmer OT spec.
18
+ Coeng: 1 << 14, // Khmer-style Virama.
19
+ Repha: 1 << 15, // Atomically-encoded logical or visual repha.
20
+ Ra: 1 << 16,
21
+ CM: 1 << 17, // Consonant-Medial.
22
+ Symbol: 1 << 18 // Avagraha, etc that take marks (SM,A,VD).
23
+ };
24
+
25
+ // Visual positions in a syllable from left to right.
26
+ export const POSITIONS = {
27
+ Start: 1 << 0,
28
+
29
+ Ra_To_Become_Reph: 1 << 1,
30
+ Pre_M: 1 << 2,
31
+ Pre_C: 1 << 3,
32
+
33
+ Base_C: 1 << 4,
34
+ After_Main: 1 << 5,
35
+
36
+ Above_C: 1 << 6,
37
+
38
+ Before_Sub: 1 << 7,
39
+ Below_C: 1 << 8,
40
+ After_Sub: 1 << 9,
41
+
42
+ Before_Post: 1 << 10,
43
+ Post_C: 1 << 11,
44
+ After_Post: 1 << 12,
45
+
46
+ Final_C: 1 << 13,
47
+ SMVD: 1 << 14,
48
+
49
+ End: 1 << 15
50
+ };
51
+
52
+ export const CONSONANT_FLAGS = CATEGORIES.C | CATEGORIES.Ra | CATEGORIES.CM | CATEGORIES.V | CATEGORIES.Placeholder | CATEGORIES.Dotted_Circle;
53
+ export const JOINER_FLAGS = CATEGORIES.ZWJ | CATEGORIES.ZWNJ;
54
+ export const HALANT_OR_COENG_FLAGS = CATEGORIES.H | CATEGORIES.Coeng;
55
+
56
+ export const INDIC_CONFIGS = {
57
+ Default: {
58
+ hasOldSpec: false,
59
+ virama: 0,
60
+ basePos: 'Last',
61
+ rephPos: POSITIONS.Before_Post,
62
+ rephMode: 'Implicit',
63
+ blwfMode: 'Pre_And_Post'
64
+ },
65
+
66
+ Devanagari: {
67
+ hasOldSpec: true,
68
+ virama: 0x094D,
69
+ basePos: 'Last',
70
+ rephPos: POSITIONS.Before_Post,
71
+ rephMode: 'Implicit',
72
+ blwfMode: 'Pre_And_Post'
73
+ },
74
+
75
+ Bengali: {
76
+ hasOldSpec: true,
77
+ virama: 0x09CD,
78
+ basePos: 'Last',
79
+ rephPos: POSITIONS.After_Sub,
80
+ rephMode: 'Implicit',
81
+ blwfMode: 'Pre_And_Post'
82
+ },
83
+
84
+ Gurmukhi: {
85
+ hasOldSpec: true,
86
+ virama: 0x0A4D,
87
+ basePos: 'Last',
88
+ rephPos: POSITIONS.Before_Sub,
89
+ rephMode: 'Implicit',
90
+ blwfMode: 'Pre_And_Post'
91
+ },
92
+
93
+ Gujarati: {
94
+ hasOldSpec: true,
95
+ virama: 0x0ACD,
96
+ basePos: 'Last',
97
+ rephPos: POSITIONS.Before_Post,
98
+ rephMode: 'Implicit',
99
+ blwfMode: 'Pre_And_Post'
100
+ },
101
+
102
+ Oriya: {
103
+ hasOldSpec: true,
104
+ virama: 0x0B4D,
105
+ basePos: 'Last',
106
+ rephPos: POSITIONS.After_Main,
107
+ rephMode: 'Implicit',
108
+ blwfMode: 'Pre_And_Post'
109
+ },
110
+
111
+ Tamil: {
112
+ hasOldSpec: true,
113
+ virama: 0x0BCD,
114
+ basePos: 'Last',
115
+ rephPos: POSITIONS.After_Post,
116
+ rephMode: 'Implicit',
117
+ blwfMode: 'Pre_And_Post'
118
+ },
119
+
120
+ Telugu: {
121
+ hasOldSpec: true,
122
+ virama: 0x0C4D,
123
+ basePos: 'Last',
124
+ rephPos: POSITIONS.After_Post,
125
+ rephMode: 'Explicit',
126
+ blwfMode: 'Post_Only'
127
+ },
128
+
129
+ Kannada: {
130
+ hasOldSpec: true,
131
+ virama: 0x0CCD,
132
+ basePos: 'Last',
133
+ rephPos: POSITIONS.After_Post,
134
+ rephMode: 'Implicit',
135
+ blwfMode: 'Post_Only'
136
+ },
137
+
138
+ Malayalam: {
139
+ hasOldSpec: true,
140
+ virama: 0x0D4D,
141
+ basePos: 'Last',
142
+ rephPos: POSITIONS.After_Main,
143
+ rephMode: 'Log_Repha',
144
+ blwfMode: 'Pre_And_Post'
145
+ },
146
+
147
+ // Handled by UniversalShaper
148
+ // Sinhala: {
149
+ // hasOldSpec: false,
150
+ // virama: 0x0DCA,
151
+ // basePos: 'Last_Sinhala',
152
+ // rephPos: POSITIONS.After_Main,
153
+ // rephMode: 'Explicit',
154
+ // blwfMode: 'Pre_And_Post'
155
+ // },
156
+
157
+ Khmer: {
158
+ hasOldSpec: false,
159
+ virama: 0x17D2,
160
+ basePos: 'First',
161
+ rephPos: POSITIONS.Ra_To_Become_Reph,
162
+ rephMode: 'Vis_Repha',
163
+ blwfMode: 'Pre_And_Post'
164
+ }
165
+ };
166
+
167
+ // Additional decompositions that aren't in Unicode
168
+ export const INDIC_DECOMPOSITIONS = {
169
+ // Khmer
170
+ 0x17BE: [0x17C1, 0x17BE],
171
+ 0x17BF: [0x17C1, 0x17BF],
172
+ 0x17C0: [0x17C1, 0x17C0],
173
+ 0x17C4: [0x17C1, 0x17C4],
174
+ 0x17C5: [0x17C1, 0x17C5]
175
+ };
node_modules/fontkit/src/opentype/shapers/indic.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"stateTable":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,2,3,4,5,6,7,8,9,0,10,11,11,12,13,14,15,16,17],[0,0,0,18,19,20,21,22,23,0,24,0,0,25,26,0,0,27,0],[0,0,0,28,29,30,31,32,33,0,34,0,0,35,36,0,0,37,0],[0,0,0,38,5,7,7,8,9,0,10,0,0,0,13,0,0,16,0],[0,39,0,0,0,40,41,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,43,44,44,8,9,0,0,0,0,12,43,0,0,0,0],[0,0,0,0,43,44,44,8,9,0,0,0,0,0,43,0,0,0,0],[0,0,0,45,46,47,48,49,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,50,0,0,51,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,52,0,0,0,0,0,0,0,0],[0,0,0,53,54,55,56,57,58,0,59,0,0,60,61,0,0,62,0],[0,0,0,4,5,7,7,8,9,0,10,0,0,0,13,0,0,16,0],[0,63,64,0,0,40,41,0,9,0,10,0,0,0,42,0,63,0,0],[0,2,3,4,5,6,7,8,9,0,10,11,11,12,13,0,2,16,0],[0,0,0,18,65,20,21,22,23,0,24,0,0,25,26,0,0,27,0],[0,0,0,0,66,67,67,8,9,0,10,0,0,0,68,0,0,0,0],[0,0,0,69,0,70,70,0,71,0,72,0,0,0,0,0,0,0,0],[0,0,0,73,19,74,74,22,23,0,24,0,0,0,26,0,0,27,0],[0,75,0,0,0,76,77,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,79,80,80,22,23,0,0,0,0,25,79,0,0,0,0],[0,0,0,18,19,20,74,22,23,0,24,0,0,25,26,0,0,27,0],[0,0,0,81,82,83,84,85,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,86,0,0,87,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,88,0,0,0,0,0,0,0,0],[0,0,0,18,19,74,74,22,23,0,24,0,0,0,26,0,0,27,0],[0,89,90,0,0,76,77,0,23,0,24,0,0,0,78,0,89,0,0],[0,0,0,0,91,92,92,22,23,0,24,0,0,0,93,0,0,0,0],[0,0,0,94,29,95,31,32,33,0,34,0,0,0,36,0,0,37,0],[0,96,0,0,0,97,98,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,100,101,101,32,33,0,0,0,0,35,100,0,0,0,0],[0,0,0,0,100,101,101,32,33,0,0,0,0,0,100,0,0,0,0],[0,0,0,102,103,104,105,106,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,107,0,0,108,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,109,0,0,0,0,0,0,0,0],[0,0,0,28,29,95,31,32,33,0,34,0,0,0,36,0,0,37,0],[0,110,111,0,0,97,98,0,33,0,34,0,0,0,99,0,110,0,0],[0,0,0,0,112,113,113,32,33,0,34,0,0,0,114,0,0,0,0],[0,0,0,0,5,7,7,8,9,0,10,0,0,0,13,0,0,16,0],[0,0,0,115,116,117,118,8,9,0,10,0,0,119,120,0,0,16,0],[0,0,0,0,0,121,121,0,9,0,10,0,0,0,42,0,0,0,0],[0,39,0,122,0,123,123,8,9,0,10,0,0,0,42,0,39,0,0],[0,124,64,0,0,0,0,0,0,0,0,0,0,0,0,0,124,0,0],[0,39,0,0,0,121,125,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,0,126,126,8,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,46,47,48,49,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,47,47,49,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,127,127,49,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,128,127,127,49,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,129,130,131,132,133,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,50,0,0,0,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,134,0,0,0,0,0,0,0,0],[0,0,0,135,54,56,56,57,58,0,59,0,0,0,61,0,0,62,0],[0,136,0,0,0,137,138,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,140,141,141,57,58,0,0,0,0,60,140,0,0,0,0],[0,0,0,0,140,141,141,57,58,0,0,0,0,0,140,0,0,0,0],[0,0,0,142,143,144,145,146,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,147,0,0,148,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,149,0,0,0,0,0,0,0,0],[0,0,0,53,54,56,56,57,58,0,59,0,0,0,61,0,0,62,0],[0,150,151,0,0,137,138,0,58,0,59,0,0,0,139,0,150,0,0],[0,0,0,0,152,153,153,57,58,0,59,0,0,0,154,0,0,0,0],[0,0,0,155,116,156,157,8,9,0,10,0,0,158,120,0,0,16,0],[0,0,0,0,0,121,121,0,9,0,10,0,0,0,0,0,0,0,0],[0,75,3,4,5,159,160,8,161,0,162,0,11,12,163,0,75,16,0],[0,0,0,0,0,40,164,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,165,44,44,8,9,0,0,0,0,0,165,0,0,0,0],[0,124,64,0,0,40,164,0,9,0,10,0,0,0,42,0,124,0,0],[0,0,0,0,0,70,70,0,71,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,71,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,166,0,0,167,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,168,0,0,0,0,0,0,0,0],[0,0,0,0,19,74,74,22,23,0,24,0,0,0,26,0,0,27,0],[0,0,0,0,79,80,80,22,23,0,0,0,0,0,79,0,0,0,0],[0,0,0,169,170,171,172,22,23,0,24,0,0,173,174,0,0,27,0],[0,0,0,0,0,175,175,0,23,0,24,0,0,0,78,0,0,0,0],[0,75,0,176,0,177,177,22,23,0,24,0,0,0,78,0,75,0,0],[0,178,90,0,0,0,0,0,0,0,0,0,0,0,0,0,178,0,0],[0,75,0,0,0,175,179,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,0,180,180,22,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,82,83,84,85,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,83,83,85,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,181,181,85,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,182,181,181,85,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,183,184,185,186,187,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,86,0,0,0,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,188,0,0,0,0,0,0,0,0],[0,0,0,189,170,190,191,22,23,0,24,0,0,192,174,0,0,27,0],[0,0,0,0,0,175,175,0,23,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,76,193,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,194,80,80,22,23,0,0,0,0,0,194,0,0,0,0],[0,178,90,0,0,76,193,0,23,0,24,0,0,0,78,0,178,0,0],[0,0,0,0,29,95,31,32,33,0,34,0,0,0,36,0,0,37,0],[0,0,0,0,100,101,101,32,33,0,0,0,0,0,100,0,0,0,0],[0,0,0,195,196,197,198,32,33,0,34,0,0,199,200,0,0,37,0],[0,0,0,0,0,201,201,0,33,0,34,0,0,0,99,0,0,0,0],[0,96,0,202,0,203,203,32,33,0,34,0,0,0,99,0,96,0,0],[0,204,111,0,0,0,0,0,0,0,0,0,0,0,0,0,204,0,0],[0,96,0,0,0,201,205,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,0,206,206,32,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,103,104,105,106,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,104,104,106,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,207,207,106,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,208,207,207,106,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,209,210,211,212,213,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,107,0,0,0,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,214,0,0,0,0,0,0,0,0],[0,0,0,215,196,216,217,32,33,0,34,0,0,218,200,0,0,37,0],[0,0,0,0,0,201,201,0,33,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,97,219,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,220,101,101,32,33,0,0,0,0,0,220,0,0,0,0],[0,204,111,0,0,97,219,0,33,0,34,0,0,0,99,0,204,0,0],[0,0,0,221,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,223,0,0,0,40,224,0,9,0,10,0,0,0,42,0,223,0,0],[0,0,0,0,225,44,44,8,9,0,0,0,0,119,225,0,0,0,0],[0,0,0,115,116,117,222,8,9,0,10,0,0,119,120,0,0,16,0],[0,0,0,115,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,226,64,0,0,40,224,0,9,0,10,0,0,0,42,0,226,0,0],[0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0],[0,39,0,0,0,121,121,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,0,44,44,8,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,227,0,228,229,0,9,0,10,0,0,230,0,0,0,0,0],[0,39,0,122,0,121,121,0,9,0,10,0,0,0,42,0,39,0,0],[0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,231,231,49,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,232,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,130,131,132,133,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,131,131,133,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,233,233,133,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,234,233,233,133,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,235,236,237,238,239,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,54,56,56,57,58,0,59,0,0,0,61,0,0,62,0],[0,0,0,240,241,242,243,57,58,0,59,0,0,244,245,0,0,62,0],[0,0,0,0,0,246,246,0,58,0,59,0,0,0,139,0,0,0,0],[0,136,0,247,0,248,248,57,58,0,59,0,0,0,139,0,136,0,0],[0,249,151,0,0,0,0,0,0,0,0,0,0,0,0,0,249,0,0],[0,136,0,0,0,246,250,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,0,251,251,57,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,143,144,145,146,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,144,144,146,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,252,252,146,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,253,252,252,146,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,254,255,256,257,258,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,147,0,0,0,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,259,0,0,0,0,0,0,0,0],[0,0,0,260,241,261,262,57,58,0,59,0,0,263,245,0,0,62,0],[0,0,0,0,0,246,246,0,58,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,137,264,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,265,141,141,57,58,0,0,0,0,0,265,0,0,0,0],[0,249,151,0,0,137,264,0,58,0,59,0,0,0,139,0,249,0,0],[0,0,0,221,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,9,0,0,0,0,158,225,0,0,0,0],[0,0,0,155,116,156,222,8,9,0,10,0,0,158,120,0,0,16,0],[0,0,0,155,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,0,0,0,43,266,266,8,161,0,24,0,0,12,267,0,0,0,0],[0,75,0,176,43,268,268,269,161,0,24,0,0,0,267,0,75,0,0],[0,0,0,0,0,270,0,0,271,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,272,0,0,0,0,0,0,0,0],[0,273,274,0,0,40,41,0,9,0,10,0,0,0,42,0,273,0,0],[0,0,0,40,0,123,123,8,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,121,275,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,166,0,0,0,0,72,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,276,0,0,0,0,0,0,0,0],[0,0,0,277,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,279,0,0,0,76,280,0,23,0,24,0,0,0,78,0,279,0,0],[0,0,0,0,281,80,80,22,23,0,0,0,0,173,281,0,0,0,0],[0,0,0,169,170,171,278,22,23,0,24,0,0,173,174,0,0,27,0],[0,0,0,169,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,282,90,0,0,76,280,0,23,0,24,0,0,0,78,0,282,0,0],[0,0,0,0,0,0,0,0,23,0,0,0,0,0,0,0,0,0,0],[0,75,0,0,0,175,175,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,0,80,80,22,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,283,0,284,285,0,23,0,24,0,0,286,0,0,0,0,0],[0,75,0,176,0,175,175,0,23,0,24,0,0,0,78,0,75,0,0],[0,0,0,0,0,0,0,22,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,287,287,85,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,288,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,184,185,186,187,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,185,185,187,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,289,289,187,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,290,289,289,187,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,291,292,293,294,295,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,277,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,0,0,0,281,80,80,22,23,0,0,0,0,192,281,0,0,0,0],[0,0,0,189,170,190,278,22,23,0,24,0,0,192,174,0,0,27,0],[0,0,0,189,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,0,0,76,0,177,177,22,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,175,296,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,297,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,299,0,0,0,97,300,0,33,0,34,0,0,0,99,0,299,0,0],[0,0,0,0,301,101,101,32,33,0,0,0,0,199,301,0,0,0,0],[0,0,0,195,196,197,298,32,33,0,34,0,0,199,200,0,0,37,0],[0,0,0,195,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,302,111,0,0,97,300,0,33,0,34,0,0,0,99,0,302,0,0],[0,0,0,0,0,0,0,0,33,0,0,0,0,0,0,0,0,0,0],[0,96,0,0,0,201,201,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,0,101,101,32,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,303,0,304,305,0,33,0,34,0,0,306,0,0,0,0,0],[0,96,0,202,0,201,201,0,33,0,34,0,0,0,99,0,96,0,0],[0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,307,307,106,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,308,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,210,211,212,213,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,211,211,213,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,309,309,213,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,310,309,309,213,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,311,312,313,314,315,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,297,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,0,0,0,301,101,101,32,33,0,0,0,0,218,301,0,0,0,0],[0,0,0,215,196,216,298,32,33,0,34,0,0,218,200,0,0,37,0],[0,0,0,215,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,0,0,97,0,203,203,32,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,201,316,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,116,222,222,8,9,0,10,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,9,0,0,0,0,0,225,0,0,0,0],[0,0,0,317,318,319,320,8,9,0,10,0,0,321,322,0,0,16,0],[0,223,0,323,0,123,123,8,9,0,10,0,0,0,42,0,223,0,0],[0,223,0,0,0,121,324,0,9,0,10,0,0,0,42,0,223,0,0],[0,0,0,325,318,326,327,8,9,0,10,0,0,328,322,0,0,16,0],[0,0,0,64,0,121,121,0,9,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,9,0,0,0,0,230,0,0,0,0,0],[0,0,0,227,0,228,121,0,9,0,10,0,0,230,0,0,0,0,0],[0,0,0,227,0,121,121,0,9,0,10,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,49,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,46,0,0],[0,0,0,0,0,329,329,133,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,330,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,236,237,238,239,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,237,237,239,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,331,331,239,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,332,331,331,239,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,333,40,121,334,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,335,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,337,0,0,0,137,338,0,58,0,59,0,0,0,139,0,337,0,0],[0,0,0,0,339,141,141,57,58,0,0,0,0,244,339,0,0,0,0],[0,0,0,240,241,242,336,57,58,0,59,0,0,244,245,0,0,62,0],[0,0,0,240,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,340,151,0,0,137,338,0,58,0,59,0,0,0,139,0,340,0,0],[0,0,0,0,0,0,0,0,58,0,0,0,0,0,0,0,0,0,0],[0,136,0,0,0,246,246,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,0,141,141,57,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,341,0,342,343,0,58,0,59,0,0,344,0,0,0,0,0],[0,136,0,247,0,246,246,0,58,0,59,0,0,0,139,0,136,0,0],[0,0,0,0,0,0,0,57,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,345,345,146,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,346,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,255,256,257,258,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,256,256,258,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,347,347,258,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,348,347,347,258,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,349,350,351,352,353,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,335,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,0,0,0,339,141,141,57,58,0,0,0,0,263,339,0,0,0,0],[0,0,0,260,241,261,336,57,58,0,59,0,0,263,245,0,0,62,0],[0,0,0,260,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,0,0,137,0,248,248,57,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,246,354,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,126,126,8,23,0,0,0,0,0,0,0,0,0,0],[0,355,90,0,0,121,125,0,9,0,10,0,0,0,42,0,355,0,0],[0,0,0,0,0,356,356,269,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,357,358,359,360,361,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,270,0,0,0,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,363,0,0,0,0,0,0,0,0],[0,0,0,364,116,365,366,8,161,0,162,0,0,367,120,0,0,16,0],[0,0,0,0,0,368,368,0,161,0,162,0,0,0,0,0,0,0,0],[0,0,0,40,0,121,121,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,170,278,278,22,23,0,24,0,0,0,174,0,0,27,0],[0,0,0,0,281,80,80,22,23,0,0,0,0,0,281,0,0,0,0],[0,0,0,369,370,371,372,22,23,0,24,0,0,373,374,0,0,27,0],[0,279,0,375,0,177,177,22,23,0,24,0,0,0,78,0,279,0,0],[0,279,0,0,0,175,376,0,23,0,24,0,0,0,78,0,279,0,0],[0,0,0,377,370,378,379,22,23,0,24,0,0,380,374,0,0,27,0],[0,0,0,90,0,175,175,0,23,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,23,0,0,0,0,286,0,0,0,0,0],[0,0,0,283,0,284,175,0,23,0,24,0,0,286,0,0,0,0,0],[0,0,0,283,0,175,175,0,23,0,24,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,85,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,82,0,0],[0,0,0,0,0,381,381,187,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,382,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,292,293,294,295,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,293,293,295,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,0,383,383,295,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,384,383,383,295,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,385,76,175,386,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,76,0,175,175,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,196,298,298,32,33,0,34,0,0,0,200,0,0,37,0],[0,0,0,0,301,101,101,32,33,0,0,0,0,0,301,0,0,0,0],[0,0,0,387,388,389,390,32,33,0,34,0,0,391,392,0,0,37,0],[0,299,0,393,0,203,203,32,33,0,34,0,0,0,99,0,299,0,0],[0,299,0,0,0,201,394,0,33,0,34,0,0,0,99,0,299,0,0],[0,0,0,395,388,396,397,32,33,0,34,0,0,398,392,0,0,37,0],[0,0,0,111,0,201,201,0,33,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,33,0,0,0,0,306,0,0,0,0,0],[0,0,0,303,0,304,201,0,33,0,34,0,0,306,0,0,0,0,0],[0,0,0,303,0,201,201,0,33,0,34,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,106,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,103,0,0],[0,0,0,0,0,399,399,213,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,400,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,312,313,314,315,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,313,313,315,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,0,401,401,315,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,402,401,401,315,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,403,97,201,404,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,97,0,201,201,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,405,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,407,0,0,0,40,408,0,9,0,10,0,0,0,42,0,407,0,0],[0,0,0,0,409,44,44,8,9,0,0,0,0,321,409,0,0,0,0],[0,0,0,317,318,319,406,8,9,0,10,0,0,321,322,0,0,16,0],[0,0,0,317,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,410,64,0,0,40,408,0,9,0,10,0,0,0,42,0,410,0,0],[0,223,0,0,0,121,121,0,9,0,10,0,0,0,42,0,223,0,0],[0,223,0,323,0,121,121,0,9,0,10,0,0,0,42,0,223,0,0],[0,0,0,405,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,0,0,0,409,44,44,8,9,0,0,0,0,328,409,0,0,0,0],[0,0,0,325,318,326,406,8,9,0,10,0,0,328,322,0,0,16,0],[0,0,0,325,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,0,0,0,0,0,0,133,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,0,0],[0,0,0,0,0,411,411,239,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,40,121,334,0,9,0,10,0,0,0,42,0,0,0,0],[0,0,0,0,413,0,0,0,9,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,241,336,336,57,58,0,59,0,0,0,245,0,0,62,0],[0,0,0,0,339,141,141,57,58,0,0,0,0,0,339,0,0,0,0],[0,0,0,414,415,416,417,57,58,0,59,0,0,418,419,0,0,62,0],[0,337,0,420,0,248,248,57,58,0,59,0,0,0,139,0,337,0,0],[0,337,0,0,0,246,421,0,58,0,59,0,0,0,139,0,337,0,0],[0,0,0,422,415,423,424,57,58,0,59,0,0,425,419,0,0,62,0],[0,0,0,151,0,246,246,0,58,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,58,0,0,0,0,344,0,0,0,0,0],[0,0,0,341,0,342,246,0,58,0,59,0,0,344,0,0,0,0,0],[0,0,0,341,0,246,246,0,58,0,59,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,146,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,143,0,0],[0,0,0,0,0,426,426,258,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,427,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,350,351,352,353,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,351,351,353,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,0,428,428,353,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,429,428,428,353,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,430,137,246,431,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,137,0,246,246,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,432,116,433,434,8,161,0,162,0,0,435,120,0,0,16,0],[0,0,0,0,0,180,180,269,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,358,359,360,361,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,359,359,361,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,436,436,361,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,437,436,436,361,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,438,439,440,441,442,161,0,162,0,0,0,362,0,0,0,0],[0,443,274,0,0,0,0,0,0,0,0,0,0,0,0,0,443,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,444,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,161,0,0,0,0,367,225,0,0,0,0],[0,0,0,364,116,365,445,8,161,0,162,0,0,367,120,0,0,16,0],[0,0,0,364,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,0,0,0,0,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,446,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,448,0,0,0,76,449,0,23,0,24,0,0,0,78,0,448,0,0],[0,0,0,0,450,80,80,22,23,0,0,0,0,373,450,0,0,0,0],[0,0,0,369,370,371,447,22,23,0,24,0,0,373,374,0,0,27,0],[0,0,0,369,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,451,90,0,0,76,449,0,23,0,24,0,0,0,78,0,451,0,0],[0,279,0,0,0,175,175,0,23,0,24,0,0,0,78,0,279,0,0],[0,279,0,375,0,175,175,0,23,0,24,0,0,0,78,0,279,0,0],[0,0,0,446,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,0,0,0,450,80,80,22,23,0,0,0,0,380,450,0,0,0,0],[0,0,0,377,370,378,447,22,23,0,24,0,0,380,374,0,0,27,0],[0,0,0,377,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,0,0,0,0,0,0,187,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,184,0,0],[0,0,0,0,0,452,452,295,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,453,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,76,175,386,0,23,0,24,0,0,0,78,0,0,0,0],[0,0,0,0,454,0,0,0,23,0,0,0,0,0,0,0,0,0,0],[0,0,0,455,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,457,0,0,0,97,458,0,33,0,34,0,0,0,99,0,457,0,0],[0,0,0,0,459,101,101,32,33,0,0,0,0,391,459,0,0,0,0],[0,0,0,387,388,389,456,32,33,0,34,0,0,391,392,0,0,37,0],[0,0,0,387,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,460,111,0,0,97,458,0,33,0,34,0,0,0,99,0,460,0,0],[0,299,0,0,0,201,201,0,33,0,34,0,0,0,99,0,299,0,0],[0,299,0,393,0,201,201,0,33,0,34,0,0,0,99,0,299,0,0],[0,0,0,455,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,0,0,0,459,101,101,32,33,0,0,0,0,398,459,0,0,0,0],[0,0,0,395,388,396,456,32,33,0,34,0,0,398,392,0,0,37,0],[0,0,0,395,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,0,0,0,0,0,0,213,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,210,0,0],[0,0,0,0,0,461,461,315,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,462,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,97,201,404,0,33,0,34,0,0,0,99,0,0,0,0],[0,0,0,0,463,0,0,0,33,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,318,406,406,8,9,0,10,0,0,0,322,0,0,16,0],[0,0,0,0,409,44,44,8,9,0,0,0,0,0,409,0,0,0,0],[0,0,0,464,465,466,467,8,9,0,10,0,0,468,469,0,0,16,0],[0,407,0,470,0,123,123,8,9,0,10,0,0,0,42,0,407,0,0],[0,407,0,0,0,121,471,0,9,0,10,0,0,0,42,0,407,0,0],[0,0,0,472,465,473,474,8,9,0,10,0,0,475,469,0,0,16,0],[0,0,0,0,0,0,0,239,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,236,0,0],[0,0,0,0,0,0,476,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,477,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,479,0,0,0,137,480,0,58,0,59,0,0,0,139,0,479,0,0],[0,0,0,0,481,141,141,57,58,0,0,0,0,418,481,0,0,0,0],[0,0,0,414,415,416,478,57,58,0,59,0,0,418,419,0,0,62,0],[0,0,0,414,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,482,151,0,0,137,480,0,58,0,59,0,0,0,139,0,482,0,0],[0,337,0,0,0,246,246,0,58,0,59,0,0,0,139,0,337,0,0],[0,337,0,420,0,246,246,0,58,0,59,0,0,0,139,0,337,0,0],[0,0,0,477,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,0,0,0,481,141,141,57,58,0,0,0,0,425,481,0,0,0,0],[0,0,0,422,415,423,478,57,58,0,59,0,0,425,419,0,0,62,0],[0,0,0,422,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,0,0,0,0,0,0,258,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0],[0,0,0,0,0,483,483,353,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,484,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,137,246,431,0,58,0,59,0,0,0,139,0,0,0,0],[0,0,0,0,485,0,0,0,58,0,0,0,0,0,0,0,0,0,0],[0,0,0,444,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,161,0,0,0,0,435,225,0,0,0,0],[0,0,0,432,116,433,445,8,161,0,162,0,0,435,120,0,0,16,0],[0,0,0,432,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,0,486,486,361,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,487,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,439,440,441,442,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,440,440,442,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,488,488,442,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,489,488,488,442,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,490,491,492,493,494,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,495,0,496,497,0,161,0,162,0,0,498,0,0,0,0,0],[0,0,0,0,116,445,445,8,161,0,162,0,0,0,120,0,0,16,0],[0,0,0,0,225,44,44,8,161,0,0,0,0,0,225,0,0,0,0],[0,0,0,0,370,447,447,22,23,0,24,0,0,0,374,0,0,27,0],[0,0,0,0,450,80,80,22,23,0,0,0,0,0,450,0,0,0,0],[0,0,0,499,500,501,502,22,23,0,24,0,0,503,504,0,0,27,0],[0,448,0,505,0,177,177,22,23,0,24,0,0,0,78,0,448,0,0],[0,448,0,0,0,175,506,0,23,0,24,0,0,0,78,0,448,0,0],[0,0,0,507,500,508,509,22,23,0,24,0,0,510,504,0,0,27,0],[0,0,0,0,0,0,0,295,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,292,0,0],[0,0,0,0,0,0,511,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,388,456,456,32,33,0,34,0,0,0,392,0,0,37,0],[0,0,0,0,459,101,101,32,33,0,0,0,0,0,459,0,0,0,0],[0,0,0,512,513,514,515,32,33,0,34,0,0,516,517,0,0,37,0],[0,457,0,518,0,203,203,32,33,0,34,0,0,0,99,0,457,0,0],[0,457,0,0,0,201,519,0,33,0,34,0,0,0,99,0,457,0,0],[0,0,0,520,513,521,522,32,33,0,34,0,0,523,517,0,0,37,0],[0,0,0,0,0,0,0,315,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,312,0,0],[0,0,0,0,0,0,524,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,525,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,527,0,0,0,40,528,0,9,0,10,0,0,0,42,0,527,0,0],[0,0,0,0,529,44,44,8,9,0,0,0,0,468,529,0,0,0,0],[0,0,0,464,465,466,526,8,9,0,10,0,0,468,469,0,0,16,0],[0,0,0,464,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,530,64,0,0,40,528,0,9,0,10,0,0,0,42,0,530,0,0],[0,407,0,0,0,121,121,0,9,0,10,0,0,0,42,0,407,0,0],[0,407,0,470,0,121,121,0,9,0,10,0,0,0,42,0,407,0,0],[0,0,0,525,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,0,0,0,529,44,44,8,9,0,0,0,0,475,529,0,0,0,0],[0,0,0,472,465,473,526,8,9,0,10,0,0,475,469,0,0,16,0],[0,0,0,472,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,0,0],[0,0,0,0,415,478,478,57,58,0,59,0,0,0,419,0,0,62,0],[0,0,0,0,481,141,141,57,58,0,0,0,0,0,481,0,0,0,0],[0,0,0,531,532,533,534,57,58,0,59,0,0,535,536,0,0,62,0],[0,479,0,537,0,248,248,57,58,0,59,0,0,0,139,0,479,0,0],[0,479,0,0,0,246,538,0,58,0,59,0,0,0,139,0,479,0,0],[0,0,0,539,532,540,541,57,58,0,59,0,0,542,536,0,0,62,0],[0,0,0,0,0,0,0,353,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,350,0,0],[0,0,0,0,0,0,543,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,361,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,358,0,0],[0,0,0,0,0,544,544,442,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,545,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,491,492,493,494,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,492,492,494,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,546,546,494,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,547,546,546,494,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,548,549,368,550,0,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,274,0,368,368,0,161,0,162,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,161,0,0,0,0,498,0,0,0,0,0],[0,0,0,495,0,496,368,0,161,0,162,0,0,498,0,0,0,0,0],[0,0,0,495,0,368,368,0,161,0,162,0,0,0,0,0,0,0,0],[0,0,0,551,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,553,0,0,0,76,554,0,23,0,24,0,0,0,78,0,553,0,0],[0,0,0,0,555,80,80,22,23,0,0,0,0,503,555,0,0,0,0],[0,0,0,499,500,501,552,22,23,0,24,0,0,503,504,0,0,27,0],[0,0,0,499,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,556,90,0,0,76,554,0,23,0,24,0,0,0,78,0,556,0,0],[0,448,0,0,0,175,175,0,23,0,24,0,0,0,78,0,448,0,0],[0,448,0,505,0,175,175,0,23,0,24,0,0,0,78,0,448,0,0],[0,0,0,551,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,0,0,0,555,80,80,22,23,0,0,0,0,510,555,0,0,0,0],[0,0,0,507,500,508,552,22,23,0,24,0,0,510,504,0,0,27,0],[0,0,0,507,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,76,0,0],[0,0,0,557,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,559,0,0,0,97,560,0,33,0,34,0,0,0,99,0,559,0,0],[0,0,0,0,561,101,101,32,33,0,0,0,0,516,561,0,0,0,0],[0,0,0,512,513,514,558,32,33,0,34,0,0,516,517,0,0,37,0],[0,0,0,512,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,562,111,0,0,97,560,0,33,0,34,0,0,0,99,0,562,0,0],[0,457,0,0,0,201,201,0,33,0,34,0,0,0,99,0,457,0,0],[0,457,0,518,0,201,201,0,33,0,34,0,0,0,99,0,457,0,0],[0,0,0,557,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,0,0,0,561,101,101,32,33,0,0,0,0,523,561,0,0,0,0],[0,0,0,520,513,521,558,32,33,0,34,0,0,523,517,0,0,37,0],[0,0,0,520,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,97,0,0],[0,0,0,0,465,526,526,8,9,0,10,0,0,0,469,0,0,16,0],[0,0,0,0,529,44,44,8,9,0,0,0,0,0,529,0,0,0,0],[0,0,0,563,66,564,565,8,9,0,10,0,0,566,68,0,0,16,0],[0,527,0,567,0,123,123,8,9,0,10,0,0,0,42,0,527,0,0],[0,527,0,0,0,121,568,0,9,0,10,0,0,0,42,0,527,0,0],[0,0,0,569,66,570,571,8,9,0,10,0,0,572,68,0,0,16,0],[0,0,0,573,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,575,0,0,0,137,576,0,58,0,59,0,0,0,139,0,575,0,0],[0,0,0,0,577,141,141,57,58,0,0,0,0,535,577,0,0,0,0],[0,0,0,531,532,533,574,57,58,0,59,0,0,535,536,0,0,62,0],[0,0,0,531,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,578,151,0,0,137,576,0,58,0,59,0,0,0,139,0,578,0,0],[0,479,0,0,0,246,246,0,58,0,59,0,0,0,139,0,479,0,0],[0,479,0,537,0,246,246,0,58,0,59,0,0,0,139,0,479,0,0],[0,0,0,573,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,0,0,0,577,141,141,57,58,0,0,0,0,542,577,0,0,0,0],[0,0,0,539,532,540,574,57,58,0,59,0,0,542,536,0,0,62,0],[0,0,0,539,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,137,0,0],[0,0,0,0,0,0,0,442,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,439,0,0],[0,0,0,0,0,579,579,494,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,580,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,549,368,550,0,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,0,368,368,0,161,0,162,0,0,0,362,0,0,0,0],[0,0,0,0,581,0,0,0,161,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,500,552,552,22,23,0,24,0,0,0,504,0,0,27,0],[0,0,0,0,555,80,80,22,23,0,0,0,0,0,555,0,0,0,0],[0,0,0,582,91,583,584,22,23,0,24,0,0,585,93,0,0,27,0],[0,553,0,586,0,177,177,22,23,0,24,0,0,0,78,0,553,0,0],[0,553,0,0,0,175,587,0,23,0,24,0,0,0,78,0,553,0,0],[0,0,0,588,91,589,590,22,23,0,24,0,0,591,93,0,0,27,0],[0,0,0,0,513,558,558,32,33,0,34,0,0,0,517,0,0,37,0],[0,0,0,0,561,101,101,32,33,0,0,0,0,0,561,0,0,0,0],[0,0,0,592,112,593,594,32,33,0,34,0,0,595,114,0,0,37,0],[0,559,0,596,0,203,203,32,33,0,34,0,0,0,99,0,559,0,0],[0,559,0,0,0,201,597,0,33,0,34,0,0,0,99,0,559,0,0],[0,0,0,598,112,599,600,32,33,0,34,0,0,601,114,0,0,37,0],[0,0,0,602,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,0,165,44,44,8,9,0,0,0,0,566,165,0,0,0,0],[0,0,0,563,66,564,67,8,9,0,10,0,0,566,68,0,0,16,0],[0,0,0,563,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,527,0,0,0,121,121,0,9,0,10,0,0,0,42,0,527,0,0],[0,527,0,567,0,121,121,0,9,0,10,0,0,0,42,0,527,0,0],[0,0,0,602,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,0,165,44,44,8,9,0,0,0,0,572,165,0,0,0,0],[0,0,0,569,66,570,67,8,9,0,10,0,0,572,68,0,0,16,0],[0,0,0,569,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,0,532,574,574,57,58,0,59,0,0,0,536,0,0,62,0],[0,0,0,0,577,141,141,57,58,0,0,0,0,0,577,0,0,0,0],[0,0,0,603,152,604,605,57,58,0,59,0,0,606,154,0,0,62,0],[0,575,0,607,0,248,248,57,58,0,59,0,0,0,139,0,575,0,0],[0,575,0,0,0,246,608,0,58,0,59,0,0,0,139,0,575,0,0],[0,0,0,609,152,610,611,57,58,0,59,0,0,612,154,0,0,62,0],[0,0,0,0,0,0,0,494,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,491,0,0],[0,0,0,0,0,0,613,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,614,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,0,194,80,80,22,23,0,0,0,0,585,194,0,0,0,0],[0,0,0,582,91,583,92,22,23,0,24,0,0,585,93,0,0,27,0],[0,0,0,582,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,553,0,0,0,175,175,0,23,0,24,0,0,0,78,0,553,0,0],[0,553,0,586,0,175,175,0,23,0,24,0,0,0,78,0,553,0,0],[0,0,0,614,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,0,194,80,80,22,23,0,0,0,0,591,194,0,0,0,0],[0,0,0,588,91,589,92,22,23,0,24,0,0,591,93,0,0,27,0],[0,0,0,588,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,615,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,220,101,101,32,33,0,0,0,0,595,220,0,0,0,0],[0,0,0,592,112,593,113,32,33,0,34,0,0,595,114,0,0,37,0],[0,0,0,592,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,559,0,0,0,201,201,0,33,0,34,0,0,0,99,0,559,0,0],[0,559,0,596,0,201,201,0,33,0,34,0,0,0,99,0,559,0,0],[0,0,0,615,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,220,101,101,32,33,0,0,0,0,601,220,0,0,0,0],[0,0,0,598,112,599,113,32,33,0,34,0,0,601,114,0,0,37,0],[0,0,0,598,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,66,67,67,8,9,0,10,0,0,0,68,0,0,16,0],[0,0,0,616,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,0,0,0,265,141,141,57,58,0,0,0,0,606,265,0,0,0,0],[0,0,0,603,152,604,153,57,58,0,59,0,0,606,154,0,0,62,0],[0,0,0,603,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,575,0,0,0,246,246,0,58,0,59,0,0,0,139,0,575,0,0],[0,575,0,607,0,246,246,0,58,0,59,0,0,0,139,0,575,0,0],[0,0,0,616,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,0,0,0,265,141,141,57,58,0,0,0,0,612,265,0,0,0,0],[0,0,0,609,152,610,153,57,58,0,59,0,0,612,154,0,0,62,0],[0,0,0,609,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,549,0,0],[0,0,0,0,91,92,92,22,23,0,24,0,0,0,93,0,0,27,0],[0,0,0,0,112,113,113,32,33,0,34,0,0,0,114,0,0,37,0],[0,0,0,0,152,153,153,57,58,0,59,0,0,0,154,0,0,62,0]],"accepting":[false,true,true,true,true,true,false,false,true,true,true,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,true,true,true,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,false,false,true,true,true,true,true,true,true,true,true,true,false,true,true,false,true,true,true,false,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,true,false,true,true,false,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,true,false,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,true,true,true,false,true,false,true,true,false,false,true,true,true,true,true,true,true,false,true,true,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,false,true,true,true,false,true,false,true,true,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,false,true,false,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,false,true,true,true,true,true,false,true,true,false,false,false,false,true,true,false,false,true,true,true,false,true,true,false,false,true,false,true,true,false,true,true,false,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,false,true,true,true,true,false,false,false,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,true,false,true,false,true,true,false,false,true,true,false,false,true,true,true,false,true,false,true,true,true,true,false,false,false,true,false,true,true,true,true,false,false,false,true,true,false,true,true,true,true,true,true,false,true,true,false,true,false,true,true,true,true,false,false,false,false,false,false,false,true,true,false,false,true,true,false,true,true,true,true,false,true,true,true,true,true,true,false,true,true,false,true,true,false,true,true,true,true,true,true,false,true,true,false,true,false,true,true,true,true,true,true,false,true,true,true,true,true,true,false,true,true,false,false,false,false,false,true,true,false,true,false,true,true,true,true,true,false,true,true,true,true,true,false,true,true,true,true,true,false,true,true,true,false,true,true,true,true,false,false,false,true,false,true,true,true,true,true,false,true,true,true,false,true,true,true,true,true,false,true,true,true,true,false,true,true,true,true,true,false,true,true,false,true,true,true],"tags":[[],["broken_cluster"],["consonant_syllable"],["vowel_syllable"],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["consonant_syllable"],["broken_cluster"],["symbol_cluster"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["broken_cluster"],["broken_cluster"],["consonant_syllable","broken_cluster"],["broken_cluster"],[],["broken_cluster"],["symbol_cluster"],[],["symbol_cluster"],["symbol_cluster"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],[],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["symbol_cluster"],["symbol_cluster"],["symbol_cluster"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],[],["consonant_syllable"],["consonant_syllable"],[],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],[],["vowel_syllable"],["vowel_syllable"],[],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],[],[],["broken_cluster"],["broken_cluster"],[],[],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["broken_cluster"],["symbol_cluster"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],[],[],["consonant_syllable"],["consonant_syllable"],[],[],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],[],[],["vowel_syllable"],["vowel_syllable"],[],[],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],[],[],[],["broken_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],[],["standalone_cluster"],["standalone_cluster"],[],[],["standalone_cluster"],["standalone_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],[],[],[],["consonant_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],[],[],[],["vowel_syllable"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],[],[],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],[],["standalone_cluster"],[],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],[],[],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],[],[],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],[],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],[],[],[],[],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],[],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],[],[],[],[],["consonant_syllable","broken_cluster"],["consonant_syllable","broken_cluster"],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],[],[],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],["consonant_syllable"],[],["consonant_syllable"],["consonant_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],["vowel_syllable"],[],["vowel_syllable"],["vowel_syllable"],["broken_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],["standalone_cluster"],[],["standalone_cluster"],["standalone_cluster"],[],["consonant_syllable"],["vowel_syllable"],["standalone_cluster"]]}
node_modules/fontkit/src/opentype/shapers/indic.machine ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ c = C | Ra; # is_consonant
2
+ n = (ZWNJ? RS)? (N N?)?; # is_consonant_modifier
3
+ z = ZWJ | ZWNJ; # is_joiner
4
+ h = H | Coeng; # is_halant_or_coeng
5
+ reph = Ra H | Repha; # possible reph
6
+
7
+ cn = c ZWJ? n?;
8
+ forced_rakar = ZWJ H ZWJ Ra;
9
+ symbol = Symbol N?;
10
+ matra_group = z{0,3} M N? (H | forced_rakar)?;
11
+ # syllable_tail = (z? SM SM? ZWNJ?)? A{0,3} VD{0,2};
12
+ syllable_tail = (z? SM SM? ZWNJ?)? A{0,3};
13
+ place_holder = Placeholder | Dotted_Circle;
14
+ halant_group = z? h (ZWJ N?)?;
15
+ final_halant_group = halant_group | h ZWNJ;
16
+ medial_group = CM?;
17
+ halant_or_matra_group = (final_halant_group | (h ZWJ)? matra_group{0,4}) (Coeng (cn | V))?;
18
+
19
+ consonant_syllable = Repha? (cn halant_group){0,4} cn medial_group halant_or_matra_group syllable_tail;
20
+ vowel_syllable = reph? V n? (ZWJ | (halant_group cn){0,4} medial_group halant_or_matra_group syllable_tail);
21
+ standalone_cluster = (Repha? Placeholder | reph? Dotted_Circle) n? (halant_group cn){0,4} medial_group halant_or_matra_group syllable_tail;
22
+ symbol_cluster = symbol syllable_tail;
23
+ broken_cluster = reph? n? (halant_group cn){0,4} medial_group halant_or_matra_group syllable_tail;
24
+
25
+ main =
26
+ consonant_syllable:consonant_syllable
27
+ | vowel_syllable:vowel_syllable
28
+ | standalone_cluster:standalone_cluster
29
+ | symbol_cluster:symbol_cluster
30
+ | broken_cluster:broken_cluster
31
+ ;
node_modules/fontkit/src/opentype/shapers/indic.trie ADDED
Binary file (3.96 kB). View file
 
node_modules/fontkit/src/opentype/shapers/use.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"categories":["O","IND","S","GB","B","FM","CGJ","VMAbv","VMPst","VAbv","VPst","CMBlw","VPre","VBlw","H","VMBlw","CMAbv","MBlw","CS","R","SUB","MPst","MPre","FAbv","FPst","FBlw","null","SMAbv","SMBlw","VMPre","ZWNJ","ZWJ","WJ","M","VS","N","HN","MAbv"],"decompositions":{"2507":[2503,2494],"2508":[2503,2519],"2888":[2887,2902],"2891":[2887,2878],"2892":[2887,2903],"3018":[3014,3006],"3019":[3015,3006],"3020":[3014,3031],"3144":[3142,3158],"3264":[3263,3285],"3271":[3270,3285],"3272":[3270,3286],"3274":[3270,3266],"3275":[3270,3266,3285],"3402":[3398,3390],"3403":[3399,3390],"3404":[3398,3415],"3546":[3545,3530],"3548":[3545,3535],"3549":[3545,3535,3530],"3550":[3545,3551],"3635":[3661,3634],"3763":[3789,3762],"3955":[3953,3954],"3957":[3953,3956],"3958":[4018,3968],"3959":[4018,3953,3968],"3960":[4019,3968],"3961":[4019,3953,3968],"3969":[3953,3968],"6971":[6970,6965],"6973":[6972,6965],"6976":[6974,6965],"6977":[6975,6965],"6979":[6978,6965],"69934":[69937,69927],"69935":[69938,69927],"70475":[70471,70462],"70476":[70471,70487],"70843":[70841,70842],"70844":[70841,70832],"70846":[70841,70845],"71098":[71096,71087],"71099":[71097,71087]},"stateTable":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[2,2,3,4,4,5,0,6,7,8,9,10,11,12,13,14,15,16,0,17,18,11,19,20,21,22,0,0,0,23,0,0,2,0,0,24,0,25],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,28,0,0,0,0,0,27,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,34,35,36,37,38,39,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,39,0,0,47],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,0,0,0,0,0,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,0,0,12,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,0,9,0,0,0,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,10,11,12,13,14,0,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,0,11,12,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,0,9,0,0,12,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,0,7,0,0,0,0,0,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,10,11,12,13,14,15,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,0,11,12,0,14,0,0,0,0,0,11,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,4,4,5,0,6,7,8,9,10,11,12,13,14,15,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,48,11,12,13,14,48,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,49,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,0,11,12,0,14,0,16,0,0,0,11,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,21,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,21,22,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,0,0,0,0,0,0,14,0,0,0,0,0,0,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,50,0,51,0],[0,0,0,0,0,5,0,6,7,8,9,0,11,12,0,14,0,16,0,0,0,11,0,20,21,22,0,0,0,23,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,28,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,0,0,0,0,0,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,0,0,36,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,0,33,0,0,0,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,34,35,36,37,38,0,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,0,33,0,0,36,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,31,0,0,0,0,0,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,34,35,36,37,38,39,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,0,0,0,0,35,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,52,35,36,37,38,52,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,53,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,40,0,0,0,35,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,43,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,45,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,0,0,0,0,0,0,38,0,0,0,0,0,0,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,29,0,30,31,32,33,0,35,36,0,38,0,40,0,0,0,35,0,43,44,45,0,0,0,46,0,0,0,0,0,0,0,0],[0,0,0,0,0,5,0,6,7,8,9,48,11,12,13,14,0,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,5,0,6,7,8,9,48,11,12,13,14,48,16,0,0,18,11,19,20,21,22,0,0,0,23,0,0,0,0,0,0,0,25],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,51,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,54,0,0],[0,0,0,0,0,29,0,30,31,32,33,52,35,36,37,38,0,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,29,0,30,31,32,33,52,35,36,37,38,52,40,0,0,41,35,42,43,44,45,0,0,0,46,0,0,0,0,0,0,0,47],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,50,0,51,0]],"accepting":[false,true,true,true,true,true,true,true,true,true,true,true,true,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],"tags":[[],["broken_cluster"],["independent_cluster"],["symbol_cluster"],["standard_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],[],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["broken_cluster"],["numeral_cluster"],["broken_cluster"],["independent_cluster"],["symbol_cluster"],["symbol_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["virama_terminated_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["standard_cluster"],["broken_cluster"],["broken_cluster"],["numeral_cluster"],["number_joiner_terminated_cluster"],["standard_cluster"],["standard_cluster"],["numeral_cluster"]]}
node_modules/fontkit/src/opentype/shapers/use.machine ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ consonant_modifiers = CMAbv* CMBlw* ((H B | SUB) VS? CMAbv? CMBlw*)*;
2
+ medial_consonants = MPre? MAbv? MBlw? MPst?;
3
+ dependent_vowels = VPre* VAbv* VBlw* VPst*;
4
+ vowel_modifiers = VMPre* VMAbv* VMBlw* VMPst*;
5
+ final_consonants = FAbv* FBlw* FPst* FM?;
6
+
7
+ virama_terminated_cluster =
8
+ R? (B | GB) VS?
9
+ consonant_modifiers
10
+ H
11
+ ;
12
+
13
+ standard_cluster =
14
+ R? (B | GB) VS?
15
+ consonant_modifiers
16
+ medial_consonants
17
+ dependent_vowels
18
+ vowel_modifiers
19
+ final_consonants
20
+ ;
21
+
22
+ broken_cluster =
23
+ R?
24
+ consonant_modifiers
25
+ medial_consonants
26
+ dependent_vowels
27
+ vowel_modifiers
28
+ final_consonants
29
+ ;
30
+
31
+ number_joiner_terminated_cluster = N VS? (HN N VS?)* HN;
32
+ numeral_cluster = N VS? (HN N VS?)*;
33
+ symbol_cluster = S VS? SMAbv* SMBlw*;
34
+ independent_cluster = (IND | O | WJ) VS?;
35
+
36
+ main =
37
+ independent_cluster:independent_cluster
38
+ | virama_terminated_cluster:virama_terminated_cluster
39
+ | standard_cluster:standard_cluster
40
+ | number_joiner_terminated_cluster:number_joiner_terminated_cluster
41
+ | numeral_cluster:numeral_cluster
42
+ | symbol_cluster:symbol_cluster
43
+ | broken_cluster:broken_cluster
44
+ ;
node_modules/fontkit/src/opentype/shapers/use.trie ADDED
Binary file (3.61 kB). View file
 
node_modules/fontkit/src/subset/CFFSubset.js ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Subset from './Subset';
2
+ import CFFTop from '../cff/CFFTop';
3
+ import CFFPrivateDict from '../cff/CFFPrivateDict';
4
+ import standardStrings from '../cff/CFFStandardStrings';
5
+
6
+ export default class CFFSubset extends Subset {
7
+ constructor(font) {
8
+ super(font);
9
+
10
+ this.cff = this.font['CFF '];
11
+ if (!this.cff) {
12
+ throw new Error('Not a CFF Font');
13
+ }
14
+ }
15
+
16
+ subsetCharstrings() {
17
+ this.charstrings = [];
18
+ let gsubrs = {};
19
+
20
+ for (let gid of this.glyphs) {
21
+ this.charstrings.push(this.cff.getCharString(gid));
22
+
23
+ let glyph = this.font.getGlyph(gid);
24
+ let path = glyph.path; // this causes the glyph to be parsed
25
+
26
+ for (let subr in glyph._usedGsubrs) {
27
+ gsubrs[subr] = true;
28
+ }
29
+ }
30
+
31
+ this.gsubrs = this.subsetSubrs(this.cff.globalSubrIndex, gsubrs);
32
+ }
33
+
34
+ subsetSubrs(subrs, used) {
35
+ let res = [];
36
+ for (let i = 0; i < subrs.length; i++) {
37
+ let subr = subrs[i];
38
+ if (used[i]) {
39
+ this.cff.stream.pos = subr.offset;
40
+ res.push(this.cff.stream.readBuffer(subr.length));
41
+ } else {
42
+ res.push(new Uint8Array([11])); // return
43
+ }
44
+ }
45
+
46
+ return res;
47
+ }
48
+
49
+ subsetFontdict(topDict) {
50
+ topDict.FDArray = [];
51
+ topDict.FDSelect = {
52
+ version: 0,
53
+ fds: []
54
+ };
55
+
56
+ let used_fds = {};
57
+ let used_subrs = [];
58
+ let fd_select = {};
59
+ for (let gid of this.glyphs) {
60
+ let fd = this.cff.fdForGlyph(gid);
61
+ if (fd == null) {
62
+ continue;
63
+ }
64
+
65
+ if (!used_fds[fd]) {
66
+ topDict.FDArray.push(Object.assign({}, this.cff.topDict.FDArray[fd]));
67
+ used_subrs.push({});
68
+ fd_select[fd] = topDict.FDArray.length - 1;
69
+ }
70
+
71
+ used_fds[fd] = true;
72
+ topDict.FDSelect.fds.push(fd_select[fd]);
73
+
74
+ let glyph = this.font.getGlyph(gid);
75
+ let path = glyph.path; // this causes the glyph to be parsed
76
+ for (let subr in glyph._usedSubrs) {
77
+ used_subrs[fd_select[fd]][subr] = true;
78
+ }
79
+ }
80
+
81
+ for (let i = 0; i < topDict.FDArray.length; i++) {
82
+ let dict = topDict.FDArray[i];
83
+ delete dict.FontName;
84
+ if (dict.Private && dict.Private.Subrs) {
85
+ dict.Private = Object.assign({}, dict.Private);
86
+ dict.Private.Subrs = this.subsetSubrs(dict.Private.Subrs, used_subrs[i]);
87
+ }
88
+ }
89
+
90
+ return;
91
+ }
92
+
93
+ createCIDFontdict(topDict) {
94
+ let used_subrs = {};
95
+ for (let gid of this.glyphs) {
96
+ let glyph = this.font.getGlyph(gid);
97
+ let path = glyph.path; // this causes the glyph to be parsed
98
+
99
+ for (let subr in glyph._usedSubrs) {
100
+ used_subrs[subr] = true;
101
+ }
102
+ }
103
+
104
+ let privateDict = Object.assign({}, this.cff.topDict.Private);
105
+ if (this.cff.topDict.Private && this.cff.topDict.Private.Subrs) {
106
+ privateDict.Subrs = this.subsetSubrs(this.cff.topDict.Private.Subrs, used_subrs);
107
+ }
108
+
109
+ topDict.FDArray = [{ Private: privateDict }];
110
+ return topDict.FDSelect = {
111
+ version: 3,
112
+ nRanges: 1,
113
+ ranges: [{ first: 0, fd: 0 }],
114
+ sentinel: this.charstrings.length
115
+ };
116
+ }
117
+
118
+ addString(string) {
119
+ if (!string) {
120
+ return null;
121
+ }
122
+
123
+ if (!this.strings) {
124
+ this.strings = [];
125
+ }
126
+
127
+ this.strings.push(string);
128
+ return standardStrings.length + this.strings.length - 1;
129
+ }
130
+
131
+ encode() {
132
+ this.subsetCharstrings();
133
+
134
+ let charset = {
135
+ version: this.charstrings.length > 255 ? 2 : 1,
136
+ ranges: [{ first: 1, nLeft: this.charstrings.length - 2 }]
137
+ };
138
+
139
+ let topDict = Object.assign({}, this.cff.topDict);
140
+ topDict.Private = null;
141
+ topDict.charset = charset;
142
+ topDict.Encoding = null;
143
+ topDict.CharStrings = this.charstrings;
144
+
145
+ for (let key of ['version', 'Notice', 'Copyright', 'FullName', 'FamilyName', 'Weight', 'PostScript', 'BaseFontName', 'FontName']) {
146
+ topDict[key] = this.addString(this.cff.string(topDict[key]));
147
+ }
148
+
149
+ topDict.ROS = [this.addString('Adobe'), this.addString('Identity'), 0];
150
+ topDict.CIDCount = this.charstrings.length;
151
+
152
+ if (this.cff.isCIDFont) {
153
+ this.subsetFontdict(topDict);
154
+ } else {
155
+ this.createCIDFontdict(topDict);
156
+ }
157
+
158
+ let top = {
159
+ version: 1,
160
+ hdrSize: this.cff.hdrSize,
161
+ offSize: 4,
162
+ header: this.cff.header,
163
+ nameIndex: [this.cff.postscriptName],
164
+ topDictIndex: [topDict],
165
+ stringIndex: this.strings,
166
+ globalSubrIndex: this.gsubrs
167
+ };
168
+
169
+ return CFFTop.toBuffer(top);
170
+ }
171
+ }
node_modules/fontkit/src/subset/Subset.js ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ const resolved = Promise.resolve();
4
+
5
+ export default class Subset {
6
+ constructor(font) {
7
+ this.font = font;
8
+ this.glyphs = [];
9
+ this.mapping = {};
10
+
11
+ // always include the missing glyph
12
+ this.includeGlyph(0);
13
+ }
14
+
15
+ includeGlyph(glyph) {
16
+ if (typeof glyph === 'object') {
17
+ glyph = glyph.id;
18
+ }
19
+
20
+ if (this.mapping[glyph] == null) {
21
+ this.glyphs.push(glyph);
22
+ this.mapping[glyph] = this.glyphs.length - 1;
23
+ }
24
+
25
+ return this.mapping[glyph];
26
+ }
27
+ }
node_modules/fontkit/src/subset/TTFSubset.js ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cloneDeep from 'clone';
2
+ import Subset from './Subset';
3
+ import Directory from '../tables/directory';
4
+ import Tables from '../tables';
5
+ import TTFGlyphEncoder from '../glyph/TTFGlyphEncoder';
6
+
7
+ export default class TTFSubset extends Subset {
8
+ constructor(font) {
9
+ super(font);
10
+ this.glyphEncoder = new TTFGlyphEncoder;
11
+ }
12
+
13
+ _addGlyph(gid) {
14
+ let glyph = this.font.getGlyph(gid);
15
+ let glyf = glyph._decode();
16
+
17
+ // get the offset to the glyph from the loca table
18
+ let curOffset = this.font.loca.offsets[gid];
19
+ let nextOffset = this.font.loca.offsets[gid + 1];
20
+
21
+ let stream = this.font._getTableStream('glyf');
22
+ stream.pos += curOffset;
23
+
24
+ let buffer = stream.readBuffer(nextOffset - curOffset);
25
+
26
+ // if it is a compound glyph, include its components
27
+ if (glyf && glyf.numberOfContours < 0) {
28
+ buffer = new Uint8Array(buffer);
29
+ let view = new DataView(buffer.buffer);
30
+ for (let component of glyf.components) {
31
+ gid = this.includeGlyph(component.glyphID);
32
+ view.setUint16(component.pos, gid);
33
+ }
34
+ } else if (glyf && this.font._variationProcessor) {
35
+ // If this is a TrueType variation glyph, re-encode the path
36
+ buffer = this.glyphEncoder.encodeSimple(glyph.path, glyf.instructions);
37
+ }
38
+
39
+ this.glyf.push(buffer);
40
+ this.loca.offsets.push(this.offset);
41
+
42
+ this.hmtx.metrics.push({
43
+ advance: glyph.advanceWidth,
44
+ bearing: glyph._getMetrics().leftBearing
45
+ });
46
+
47
+ this.offset += buffer.length;
48
+ return this.glyf.length - 1;
49
+ }
50
+
51
+ encode() {
52
+ // tables required by PDF spec:
53
+ // head, hhea, loca, maxp, cvt , prep, glyf, hmtx, fpgm
54
+ //
55
+ // additional tables required for standalone fonts:
56
+ // name, cmap, OS/2, post
57
+
58
+ this.glyf = [];
59
+ this.offset = 0;
60
+ this.loca = {
61
+ offsets: [],
62
+ version: this.font.loca.version
63
+ };
64
+
65
+ this.hmtx = {
66
+ metrics: [],
67
+ bearings: []
68
+ };
69
+
70
+ // include all the glyphs
71
+ // not using a for loop because we need to support adding more
72
+ // glyphs to the array as we go, and CoffeeScript caches the length.
73
+ let i = 0;
74
+ while (i < this.glyphs.length) {
75
+ this._addGlyph(this.glyphs[i++]);
76
+ }
77
+
78
+ let maxp = cloneDeep(this.font.maxp);
79
+ maxp.numGlyphs = this.glyf.length;
80
+
81
+ this.loca.offsets.push(this.offset);
82
+
83
+ let head = cloneDeep(this.font.head);
84
+ head.indexToLocFormat = this.loca.version;
85
+
86
+ let hhea = cloneDeep(this.font.hhea);
87
+ hhea.numberOfMetrics = this.hmtx.metrics.length;
88
+
89
+ // map = []
90
+ // for index in [0...256]
91
+ // if index < @numGlyphs
92
+ // map[index] = index
93
+ // else
94
+ // map[index] = 0
95
+ //
96
+ // cmapTable =
97
+ // version: 0
98
+ // length: 262
99
+ // language: 0
100
+ // codeMap: map
101
+ //
102
+ // cmap =
103
+ // version: 0
104
+ // numSubtables: 1
105
+ // tables: [
106
+ // platformID: 1
107
+ // encodingID: 0
108
+ // table: cmapTable
109
+ // ]
110
+
111
+ // TODO: subset prep, cvt, fpgm?
112
+ return Directory.toBuffer({
113
+ tables: {
114
+ head,
115
+ hhea,
116
+ loca: this.loca,
117
+ maxp,
118
+ 'cvt ': this.font['cvt '],
119
+ prep: this.font.prep,
120
+ glyf: this.glyf,
121
+ hmtx: this.hmtx,
122
+ fpgm: this.font.fpgm
123
+
124
+ // name: clone @font.name
125
+ // 'OS/2': clone @font['OS/2']
126
+ // post: clone @font.post
127
+ // cmap: cmap
128
+ }
129
+ });
130
+ }
131
+ }
node_modules/fontkit/src/tables/BASE.js ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+ import {ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device} from './opentype';
3
+ import {ItemVariationStore} from './variations';
4
+
5
+ let BaseCoord = new r.VersionedStruct(r.uint16, {
6
+ 1: { // Design units only
7
+ coordinate: r.int16 // X or Y value, in design units
8
+ },
9
+
10
+ 2: { // Design units plus contour point
11
+ coordinate: r.int16, // X or Y value, in design units
12
+ referenceGlyph: r.uint16, // GlyphID of control glyph
13
+ baseCoordPoint: r.uint16 // Index of contour point on the referenceGlyph
14
+ },
15
+
16
+ 3: { // Design units plus Device table
17
+ coordinate: r.int16, // X or Y value, in design units
18
+ deviceTable: new r.Pointer(r.uint16, Device) // Device table for X or Y value
19
+ }
20
+ });
21
+
22
+ let BaseValues = new r.Struct({
23
+ defaultIndex: r.uint16, // Index of default baseline for this script-same index in the BaseTagList
24
+ baseCoordCount: r.uint16,
25
+ baseCoords: new r.Array(new r.Pointer(r.uint16, BaseCoord), 'baseCoordCount')
26
+ });
27
+
28
+ let FeatMinMaxRecord = new r.Struct({
29
+ tag: new r.String(4), // 4-byte feature identification tag-must match FeatureTag in FeatureList
30
+ minCoord: new r.Pointer(r.uint16, BaseCoord, {type: 'parent'}), // May be NULL
31
+ maxCoord: new r.Pointer(r.uint16, BaseCoord, {type: 'parent'}) // May be NULL
32
+ });
33
+
34
+ let MinMax = new r.Struct({
35
+ minCoord: new r.Pointer(r.uint16, BaseCoord), // May be NULL
36
+ maxCoord: new r.Pointer(r.uint16, BaseCoord), // May be NULL
37
+ featMinMaxCount: r.uint16, // May be 0
38
+ featMinMaxRecords: new r.Array(FeatMinMaxRecord, 'featMinMaxCount') // In alphabetical order
39
+ });
40
+
41
+ let BaseLangSysRecord = new r.Struct({
42
+ tag: new r.String(4), // 4-byte language system identification tag
43
+ minMax: new r.Pointer(r.uint16, MinMax, {type: 'parent'})
44
+ });
45
+
46
+ let BaseScript = new r.Struct({
47
+ baseValues: new r.Pointer(r.uint16, BaseValues), // May be NULL
48
+ defaultMinMax: new r.Pointer(r.uint16, MinMax), // May be NULL
49
+ baseLangSysCount: r.uint16, // May be 0
50
+ baseLangSysRecords: new r.Array(BaseLangSysRecord, 'baseLangSysCount') // in alphabetical order by BaseLangSysTag
51
+ });
52
+
53
+ let BaseScriptRecord = new r.Struct({
54
+ tag: new r.String(4), // 4-byte script identification tag
55
+ script: new r.Pointer(r.uint16, BaseScript, {type: 'parent'})
56
+ });
57
+
58
+ let BaseScriptList = new r.Array(BaseScriptRecord, r.uint16);
59
+
60
+ // Array of 4-byte baseline identification tags-must be in alphabetical order
61
+ let BaseTagList = new r.Array(new r.String(4), r.uint16);
62
+
63
+ let Axis = new r.Struct({
64
+ baseTagList: new r.Pointer(r.uint16, BaseTagList), // May be NULL
65
+ baseScriptList: new r.Pointer(r.uint16, BaseScriptList)
66
+ });
67
+
68
+ export default new r.VersionedStruct(r.uint32, {
69
+ header: {
70
+ horizAxis: new r.Pointer(r.uint16, Axis), // May be NULL
71
+ vertAxis: new r.Pointer(r.uint16, Axis) // May be NULL
72
+ },
73
+
74
+ 0x00010000: {},
75
+ 0x00010001: {
76
+ itemVariationStore: new r.Pointer(r.uint32, ItemVariationStore)
77
+ }
78
+ });
node_modules/fontkit/src/tables/COLR.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ let LayerRecord = new r.Struct({
4
+ gid: r.uint16, // Glyph ID of layer glyph (must be in z-order from bottom to top).
5
+ paletteIndex: r.uint16 // Index value to use in the appropriate palette. This value must
6
+ }); // be less than numPaletteEntries in the CPAL table, except for
7
+ // the special case noted below. Each palette entry is 16 bits.
8
+ // A palette index of 0xFFFF is a special case indicating that
9
+ // the text foreground color should be used.
10
+
11
+ let BaseGlyphRecord = new r.Struct({
12
+ gid: r.uint16, // Glyph ID of reference glyph. This glyph is for reference only
13
+ // and is not rendered for color.
14
+ firstLayerIndex: r.uint16, // Index (from beginning of the Layer Records) to the layer record.
15
+ // There will be numLayers consecutive entries for this base glyph.
16
+ numLayers: r.uint16
17
+ });
18
+
19
+ export default new r.Struct({
20
+ version: r.uint16,
21
+ numBaseGlyphRecords: r.uint16,
22
+ baseGlyphRecord: new r.Pointer(r.uint32, new r.Array(BaseGlyphRecord, 'numBaseGlyphRecords')),
23
+ layerRecords: new r.Pointer(r.uint32, new r.Array(LayerRecord, 'numLayerRecords'), { lazy: true }),
24
+ numLayerRecords: r.uint16
25
+ });
node_modules/fontkit/src/tables/CPAL.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ let ColorRecord = new r.Struct({
4
+ blue: r.uint8,
5
+ green: r.uint8,
6
+ red: r.uint8,
7
+ alpha: r.uint8
8
+ });
9
+
10
+ export default new r.VersionedStruct(r.uint16, {
11
+ header: {
12
+ numPaletteEntries: r.uint16,
13
+ numPalettes: r.uint16,
14
+ numColorRecords: r.uint16,
15
+ colorRecords: new r.Pointer(r.uint32, new r.Array(ColorRecord, 'numColorRecords')),
16
+ colorRecordIndices: new r.Array(r.uint16, 'numPalettes'),
17
+ },
18
+ 0: {},
19
+ 1: {
20
+ offsetPaletteTypeArray: new r.Pointer(r.uint32, new r.Array(r.uint32, 'numPalettes')),
21
+ offsetPaletteLabelArray: new r.Pointer(r.uint32, new r.Array(r.uint16, 'numPalettes')),
22
+ offsetPaletteEntryLabelArray: new r.Pointer(r.uint32, new r.Array(r.uint16, 'numPaletteEntries'))
23
+ }
24
+ });
node_modules/fontkit/src/tables/DSIG.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ let Signature = new r.Struct({
4
+ format: r.uint32,
5
+ length: r.uint32,
6
+ offset: r.uint32
7
+ });
8
+
9
+ let SignatureBlock = new r.Struct({
10
+ reserved: new r.Reserved(r.uint16, 2),
11
+ cbSignature: r.uint32, // Length (in bytes) of the PKCS#7 packet in pbSignature
12
+ signature: new r.Buffer('cbSignature')
13
+ });
14
+
15
+ export default new r.Struct({
16
+ ulVersion: r.uint32, // Version number of the DSIG table (0x00000001)
17
+ usNumSigs: r.uint16, // Number of signatures in the table
18
+ usFlag: r.uint16, // Permission flags
19
+ signatures: new r.Array(Signature, 'usNumSigs'),
20
+ signatureBlocks: new r.Array(SignatureBlock, 'usNumSigs')
21
+ });
node_modules/fontkit/src/tables/EBDT.js ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ export let BigMetrics = new r.Struct({
4
+ height: r.uint8,
5
+ width: r.uint8,
6
+ horiBearingX: r.int8,
7
+ horiBearingY: r.int8,
8
+ horiAdvance: r.uint8,
9
+ vertBearingX: r.int8,
10
+ vertBearingY: r.int8,
11
+ vertAdvance: r.uint8
12
+ });
13
+
14
+ export let SmallMetrics = new r.Struct({
15
+ height: r.uint8,
16
+ width: r.uint8,
17
+ bearingX: r.int8,
18
+ bearingY: r.int8,
19
+ advance: r.uint8
20
+ });
21
+
22
+ let EBDTComponent = new r.Struct({
23
+ glyph: r.uint16,
24
+ xOffset: r.int8,
25
+ yOffset: r.int8
26
+ });
27
+
28
+ class ByteAligned {}
29
+
30
+ class BitAligned {}
31
+
32
+ export let glyph = new r.VersionedStruct('version', {
33
+ 1: {
34
+ metrics: SmallMetrics,
35
+ data: ByteAligned
36
+ },
37
+
38
+ 2: {
39
+ metrics: SmallMetrics,
40
+ data: BitAligned
41
+ },
42
+
43
+ // format 3 is deprecated
44
+ // format 4 is not supported by Microsoft
45
+
46
+ 5: {
47
+ data: BitAligned
48
+ },
49
+
50
+ 6: {
51
+ metrics: BigMetrics,
52
+ data: ByteAligned
53
+ },
54
+
55
+ 7: {
56
+ metrics: BigMetrics,
57
+ data: BitAligned
58
+ },
59
+
60
+ 8: {
61
+ metrics: SmallMetrics,
62
+ pad: new r.Reserved(r.uint8),
63
+ numComponents: r.uint16,
64
+ components: new r.Array(EBDTComponent, 'numComponents')
65
+ },
66
+
67
+ 9: {
68
+ metrics: BigMetrics,
69
+ pad: new r.Reserved(r.uint8),
70
+ numComponents: r.uint16,
71
+ components: new r.Array(EBDTComponent, 'numComponents')
72
+ },
73
+
74
+ 17: {
75
+ metrics: SmallMetrics,
76
+ dataLen: r.uint32,
77
+ data: new r.Buffer('dataLen')
78
+ },
79
+
80
+ 18: {
81
+ metrics: BigMetrics,
82
+ dataLen: r.uint32,
83
+ data: new r.Buffer('dataLen')
84
+ },
85
+
86
+ 19: {
87
+ dataLen: r.uint32,
88
+ data: new r.Buffer('dataLen')
89
+ }
90
+ });
91
+
node_modules/fontkit/src/tables/EBLC.js ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+ import {BigMetrics} from './EBDT';
3
+
4
+ let SBitLineMetrics = new r.Struct({
5
+ ascender: r.int8,
6
+ descender: r.int8,
7
+ widthMax: r.uint8,
8
+ caretSlopeNumerator: r.int8,
9
+ caretSlopeDenominator: r.int8,
10
+ caretOffset: r.int8,
11
+ minOriginSB: r.int8,
12
+ minAdvanceSB: r.int8,
13
+ maxBeforeBL: r.int8,
14
+ minAfterBL: r.int8,
15
+ pad: new r.Reserved(r.int8, 2)
16
+ });
17
+
18
+ let CodeOffsetPair = new r.Struct({
19
+ glyphCode: r.uint16,
20
+ offset: r.uint16
21
+ });
22
+
23
+ let IndexSubtable = new r.VersionedStruct(r.uint16, {
24
+ header: {
25
+ imageFormat: r.uint16,
26
+ imageDataOffset: r.uint32
27
+ },
28
+
29
+ 1: {
30
+ offsetArray: new r.Array(r.uint32, t => t.parent.lastGlyphIndex - t.parent.firstGlyphIndex + 1)
31
+ },
32
+
33
+ 2: {
34
+ imageSize: r.uint32,
35
+ bigMetrics: BigMetrics
36
+ },
37
+
38
+ 3: {
39
+ offsetArray: new r.Array(r.uint16, t => t.parent.lastGlyphIndex - t.parent.firstGlyphIndex + 1)
40
+ },
41
+
42
+ 4: {
43
+ numGlyphs: r.uint32,
44
+ glyphArray: new r.Array(CodeOffsetPair, t => t.numGlyphs + 1)
45
+ },
46
+
47
+ 5: {
48
+ imageSize: r.uint32,
49
+ bigMetrics: BigMetrics,
50
+ numGlyphs: r.uint32,
51
+ glyphCodeArray: new r.Array(r.uint16, 'numGlyphs')
52
+ }
53
+ });
54
+
55
+ let IndexSubtableArray = new r.Struct({
56
+ firstGlyphIndex: r.uint16,
57
+ lastGlyphIndex: r.uint16,
58
+ subtable: new r.Pointer(r.uint32, IndexSubtable)
59
+ });
60
+
61
+ let BitmapSizeTable = new r.Struct({
62
+ indexSubTableArray: new r.Pointer(r.uint32, new r.Array(IndexSubtableArray, 1), { type: 'parent' }),
63
+ indexTablesSize: r.uint32,
64
+ numberOfIndexSubTables: r.uint32,
65
+ colorRef: r.uint32,
66
+ hori: SBitLineMetrics,
67
+ vert: SBitLineMetrics,
68
+ startGlyphIndex: r.uint16,
69
+ endGlyphIndex: r.uint16,
70
+ ppemX: r.uint8,
71
+ ppemY: r.uint8,
72
+ bitDepth: r.uint8,
73
+ flags: new r.Bitfield(r.uint8, ['horizontal', 'vertical'])
74
+ });
75
+
76
+ export default new r.Struct({
77
+ version: r.uint32, // 0x00020000
78
+ numSizes: r.uint32,
79
+ sizes: new r.Array(BitmapSizeTable, 'numSizes')
80
+ });
node_modules/fontkit/src/tables/GDEF.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+ import {ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device} from './opentype';
3
+ import {ItemVariationStore} from './variations';
4
+
5
+ let AttachPoint = new r.Array(r.uint16, r.uint16);
6
+ let AttachList = new r.Struct({
7
+ coverage: new r.Pointer(r.uint16, Coverage),
8
+ glyphCount: r.uint16,
9
+ attachPoints: new r.Array(new r.Pointer(r.uint16, AttachPoint), 'glyphCount')
10
+ });
11
+
12
+ let CaretValue = new r.VersionedStruct(r.uint16, {
13
+ 1: { // Design units only
14
+ coordinate: r.int16
15
+ },
16
+
17
+ 2: { // Contour point
18
+ caretValuePoint: r.uint16
19
+ },
20
+
21
+ 3: { // Design units plus Device table
22
+ coordinate: r.int16,
23
+ deviceTable: new r.Pointer(r.uint16, Device)
24
+ }
25
+ });
26
+
27
+ let LigGlyph = new r.Array(new r.Pointer(r.uint16, CaretValue), r.uint16);
28
+
29
+ let LigCaretList = new r.Struct({
30
+ coverage: new r.Pointer(r.uint16, Coverage),
31
+ ligGlyphCount: r.uint16,
32
+ ligGlyphs: new r.Array(new r.Pointer(r.uint16, LigGlyph), 'ligGlyphCount')
33
+ });
34
+
35
+ let MarkGlyphSetsDef = new r.Struct({
36
+ markSetTableFormat: r.uint16,
37
+ markSetCount: r.uint16,
38
+ coverage: new r.Array(new r.Pointer(r.uint32, Coverage), 'markSetCount')
39
+ });
40
+
41
+ export default new r.VersionedStruct(r.uint32, {
42
+ header: {
43
+ glyphClassDef: new r.Pointer(r.uint16, ClassDef),
44
+ attachList: new r.Pointer(r.uint16, AttachList),
45
+ ligCaretList: new r.Pointer(r.uint16, LigCaretList),
46
+ markAttachClassDef: new r.Pointer(r.uint16, ClassDef)
47
+ },
48
+
49
+ 0x00010000: {},
50
+ 0x00010002: {
51
+ markGlyphSetsDef: new r.Pointer(r.uint16, MarkGlyphSetsDef)
52
+ },
53
+ 0x00010003: {
54
+ markGlyphSetsDef: new r.Pointer(r.uint16, MarkGlyphSetsDef),
55
+ itemVariationStore: new r.Pointer(r.uint32, ItemVariationStore)
56
+ }
57
+ });
node_modules/fontkit/src/tables/GPOS.js ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+ import {ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device, Context, ChainingContext} from './opentype';
3
+ import {FeatureVariations} from './variations';
4
+
5
+ let ValueFormat = new r.Bitfield(r.uint16, [
6
+ 'xPlacement', 'yPlacement',
7
+ 'xAdvance', 'yAdvance',
8
+ 'xPlaDevice', 'yPlaDevice',
9
+ 'xAdvDevice', 'yAdvDevice'
10
+ ]);
11
+
12
+ let types = {
13
+ xPlacement: r.int16,
14
+ yPlacement: r.int16,
15
+ xAdvance: r.int16,
16
+ yAdvance: r.int16,
17
+ xPlaDevice: new r.Pointer(r.uint16, Device, { type: 'global', relativeTo: ctx => ctx.rel }),
18
+ yPlaDevice: new r.Pointer(r.uint16, Device, { type: 'global', relativeTo: ctx => ctx.rel }),
19
+ xAdvDevice: new r.Pointer(r.uint16, Device, { type: 'global', relativeTo: ctx => ctx.rel }),
20
+ yAdvDevice: new r.Pointer(r.uint16, Device, { type: 'global', relativeTo: ctx => ctx.rel })
21
+ };
22
+
23
+ class ValueRecord {
24
+ constructor(key = 'valueFormat') {
25
+ this.key = key;
26
+ }
27
+
28
+ buildStruct(parent) {
29
+ let struct = parent;
30
+ while (!struct[this.key] && struct.parent) {
31
+ struct = struct.parent;
32
+ }
33
+
34
+ if (!struct[this.key]) return;
35
+
36
+ let fields = {};
37
+ fields.rel = () => struct._startOffset;
38
+
39
+ let format = struct[this.key];
40
+ for (let key in format) {
41
+ if (format[key]) {
42
+ fields[key] = types[key];
43
+ }
44
+ }
45
+
46
+ return new r.Struct(fields);
47
+ }
48
+
49
+ size(val, ctx) {
50
+ return this.buildStruct(ctx).size(val, ctx);
51
+ }
52
+
53
+ decode(stream, parent) {
54
+ let res = this.buildStruct(parent).decode(stream, parent);
55
+ delete res.rel;
56
+ return res;
57
+ }
58
+ }
59
+
60
+ let PairValueRecord = new r.Struct({
61
+ secondGlyph: r.uint16,
62
+ value1: new ValueRecord('valueFormat1'),
63
+ value2: new ValueRecord('valueFormat2')
64
+ });
65
+
66
+ let PairSet = new r.Array(PairValueRecord, r.uint16);
67
+
68
+ let Class2Record = new r.Struct({
69
+ value1: new ValueRecord('valueFormat1'),
70
+ value2: new ValueRecord('valueFormat2')
71
+ });
72
+
73
+ let Anchor = new r.VersionedStruct(r.uint16, {
74
+ 1: { // Design units only
75
+ xCoordinate: r.int16,
76
+ yCoordinate: r.int16
77
+ },
78
+
79
+ 2: { // Design units plus contour point
80
+ xCoordinate: r.int16,
81
+ yCoordinate: r.int16,
82
+ anchorPoint: r.uint16
83
+ },
84
+
85
+ 3: { // Design units plus Device tables
86
+ xCoordinate: r.int16,
87
+ yCoordinate: r.int16,
88
+ xDeviceTable: new r.Pointer(r.uint16, Device),
89
+ yDeviceTable: new r.Pointer(r.uint16, Device)
90
+ }
91
+ });
92
+
93
+ let EntryExitRecord = new r.Struct({
94
+ entryAnchor: new r.Pointer(r.uint16, Anchor, {type: 'parent'}),
95
+ exitAnchor: new r.Pointer(r.uint16, Anchor, {type: 'parent'})
96
+ });
97
+
98
+ let MarkRecord = new r.Struct({
99
+ class: r.uint16,
100
+ markAnchor: new r.Pointer(r.uint16, Anchor, {type: 'parent'})
101
+ });
102
+
103
+ let MarkArray = new r.Array(MarkRecord, r.uint16);
104
+
105
+ let BaseRecord = new r.Array(new r.Pointer(r.uint16, Anchor), t => t.parent.classCount);
106
+ let BaseArray = new r.Array(BaseRecord, r.uint16);
107
+
108
+ let ComponentRecord = new r.Array(new r.Pointer(r.uint16, Anchor), t => t.parent.parent.classCount);
109
+ let LigatureAttach = new r.Array(ComponentRecord, r.uint16);
110
+ let LigatureArray = new r.Array(new r.Pointer(r.uint16, LigatureAttach), r.uint16);
111
+
112
+ let GPOSLookup = new r.VersionedStruct('lookupType', {
113
+ 1: new r.VersionedStruct(r.uint16, { // Single Adjustment
114
+ 1: { // Single positioning value
115
+ coverage: new r.Pointer(r.uint16, Coverage),
116
+ valueFormat: ValueFormat,
117
+ value: new ValueRecord()
118
+ },
119
+ 2: {
120
+ coverage: new r.Pointer(r.uint16, Coverage),
121
+ valueFormat: ValueFormat,
122
+ valueCount: r.uint16,
123
+ values: new r.LazyArray(new ValueRecord(), 'valueCount')
124
+ }
125
+ }),
126
+
127
+ 2: new r.VersionedStruct(r.uint16, { // Pair Adjustment Positioning
128
+ 1: { // Adjustments for glyph pairs
129
+ coverage: new r.Pointer(r.uint16, Coverage),
130
+ valueFormat1: ValueFormat,
131
+ valueFormat2: ValueFormat,
132
+ pairSetCount: r.uint16,
133
+ pairSets: new r.LazyArray(new r.Pointer(r.uint16, PairSet), 'pairSetCount')
134
+ },
135
+
136
+ 2: { // Class pair adjustment
137
+ coverage: new r.Pointer(r.uint16, Coverage),
138
+ valueFormat1: ValueFormat,
139
+ valueFormat2: ValueFormat,
140
+ classDef1: new r.Pointer(r.uint16, ClassDef),
141
+ classDef2: new r.Pointer(r.uint16, ClassDef),
142
+ class1Count: r.uint16,
143
+ class2Count: r.uint16,
144
+ classRecords: new r.LazyArray(new r.LazyArray(Class2Record, 'class2Count'), 'class1Count')
145
+ }
146
+ }),
147
+
148
+ 3: { // Cursive Attachment Positioning
149
+ format: r.uint16,
150
+ coverage: new r.Pointer(r.uint16, Coverage),
151
+ entryExitCount: r.uint16,
152
+ entryExitRecords: new r.Array(EntryExitRecord, 'entryExitCount')
153
+ },
154
+
155
+ 4: { // MarkToBase Attachment Positioning
156
+ format: r.uint16,
157
+ markCoverage: new r.Pointer(r.uint16, Coverage),
158
+ baseCoverage: new r.Pointer(r.uint16, Coverage),
159
+ classCount: r.uint16,
160
+ markArray: new r.Pointer(r.uint16, MarkArray),
161
+ baseArray: new r.Pointer(r.uint16, BaseArray)
162
+ },
163
+
164
+ 5: { // MarkToLigature Attachment Positioning
165
+ format: r.uint16,
166
+ markCoverage: new r.Pointer(r.uint16, Coverage),
167
+ ligatureCoverage: new r.Pointer(r.uint16, Coverage),
168
+ classCount: r.uint16,
169
+ markArray: new r.Pointer(r.uint16, MarkArray),
170
+ ligatureArray: new r.Pointer(r.uint16, LigatureArray)
171
+ },
172
+
173
+ 6: { // MarkToMark Attachment Positioning
174
+ format: r.uint16,
175
+ mark1Coverage: new r.Pointer(r.uint16, Coverage),
176
+ mark2Coverage: new r.Pointer(r.uint16, Coverage),
177
+ classCount: r.uint16,
178
+ mark1Array: new r.Pointer(r.uint16, MarkArray),
179
+ mark2Array: new r.Pointer(r.uint16, BaseArray)
180
+ },
181
+
182
+ 7: Context, // Contextual positioning
183
+ 8: ChainingContext, // Chaining contextual positioning
184
+
185
+ 9: { // Extension Positioning
186
+ posFormat: r.uint16,
187
+ lookupType: r.uint16, // cannot also be 9
188
+ extension: new r.Pointer(r.uint32, null)
189
+ }
190
+ });
191
+
192
+ // Fix circular reference
193
+ GPOSLookup.versions[9].extension.type = GPOSLookup;
194
+
195
+ export default new r.VersionedStruct(r.uint32, {
196
+ header: {
197
+ scriptList: new r.Pointer(r.uint16, ScriptList),
198
+ featureList: new r.Pointer(r.uint16, FeatureList),
199
+ lookupList: new r.Pointer(r.uint16, new LookupList(GPOSLookup))
200
+ },
201
+
202
+ 0x00010000: {},
203
+ 0x00010001: {
204
+ featureVariations: new r.Pointer(r.uint32, FeatureVariations)
205
+ }
206
+ });
207
+
208
+ // export GPOSLookup for JSTF table
209
+ export { GPOSLookup };
node_modules/fontkit/src/tables/GSUB.js ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+ import {ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device, Context, ChainingContext} from './opentype';
3
+ import {FeatureVariations} from './variations';
4
+
5
+ let Sequence = new r.Array(r.uint16, r.uint16);
6
+ let AlternateSet = Sequence;
7
+
8
+ let Ligature = new r.Struct({
9
+ glyph: r.uint16,
10
+ compCount: r.uint16,
11
+ components: new r.Array(r.uint16, t => t.compCount - 1)
12
+ });
13
+
14
+ let LigatureSet = new r.Array(new r.Pointer(r.uint16, Ligature), r.uint16);
15
+
16
+ let GSUBLookup = new r.VersionedStruct('lookupType', {
17
+ 1: new r.VersionedStruct(r.uint16, {// Single Substitution
18
+ 1: {
19
+ coverage: new r.Pointer(r.uint16, Coverage),
20
+ deltaGlyphID: r.int16
21
+ },
22
+ 2: {
23
+ coverage: new r.Pointer(r.uint16, Coverage),
24
+ glyphCount: r.uint16,
25
+ substitute: new r.LazyArray(r.uint16, 'glyphCount')
26
+ }
27
+ }),
28
+
29
+ 2: { // Multiple Substitution
30
+ substFormat: r.uint16,
31
+ coverage: new r.Pointer(r.uint16, Coverage),
32
+ count: r.uint16,
33
+ sequences: new r.LazyArray(new r.Pointer(r.uint16, Sequence), 'count')
34
+ },
35
+
36
+ 3: { // Alternate Substitution
37
+ substFormat: r.uint16,
38
+ coverage: new r.Pointer(r.uint16, Coverage),
39
+ count: r.uint16,
40
+ alternateSet: new r.LazyArray(new r.Pointer(r.uint16, AlternateSet), 'count')
41
+ },
42
+
43
+ 4: { // Ligature Substitution
44
+ substFormat: r.uint16,
45
+ coverage: new r.Pointer(r.uint16, Coverage),
46
+ count: r.uint16,
47
+ ligatureSets: new r.LazyArray(new r.Pointer(r.uint16, LigatureSet), 'count')
48
+ },
49
+
50
+ 5: Context, // Contextual Substitution
51
+ 6: ChainingContext, // Chaining Contextual Substitution
52
+
53
+ 7: { // Extension Substitution
54
+ substFormat: r.uint16,
55
+ lookupType: r.uint16, // cannot also be 7
56
+ extension: new r.Pointer(r.uint32, null)
57
+ },
58
+
59
+ 8: { // Reverse Chaining Contextual Single Substitution
60
+ substFormat: r.uint16,
61
+ coverage: new r.Pointer(r.uint16, Coverage),
62
+ backtrackCoverage: new r.Array(new r.Pointer(r.uint16, Coverage), 'backtrackGlyphCount'),
63
+ lookaheadGlyphCount: r.uint16,
64
+ lookaheadCoverage: new r.Array(new r.Pointer(r.uint16, Coverage), 'lookaheadGlyphCount'),
65
+ glyphCount: r.uint16,
66
+ substitutes: new r.Array(r.uint16, 'glyphCount')
67
+ }
68
+ });
69
+
70
+ // Fix circular reference
71
+ GSUBLookup.versions[7].extension.type = GSUBLookup;
72
+
73
+ export default new r.VersionedStruct(r.uint32, {
74
+ header: {
75
+ scriptList: new r.Pointer(r.uint16, ScriptList),
76
+ featureList: new r.Pointer(r.uint16, FeatureList),
77
+ lookupList: new r.Pointer(r.uint16, new LookupList(GSUBLookup))
78
+ },
79
+
80
+ 0x00010000: {},
81
+ 0x00010001: {
82
+ featureVariations: new r.Pointer(r.uint32, FeatureVariations)
83
+ }
84
+ });
node_modules/fontkit/src/tables/HVAR.js ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+ import { resolveLength } from 'restructure';
3
+ import { ItemVariationStore } from './variations';
4
+
5
+ // TODO: add this to restructure
6
+ class VariableSizeNumber {
7
+ constructor(size) {
8
+ this._size = size;
9
+ }
10
+
11
+ decode(stream, parent) {
12
+ switch (this.size(0, parent)) {
13
+ case 1: return stream.readUInt8();
14
+ case 2: return stream.readUInt16BE();
15
+ case 3: return stream.readUInt24BE();
16
+ case 4: return stream.readUInt32BE();
17
+ }
18
+ }
19
+
20
+ size(val, parent) {
21
+ return resolveLength(this._size, null, parent);
22
+ }
23
+ }
24
+
25
+ let MapDataEntry = new r.Struct({
26
+ entry: new VariableSizeNumber(t => ((t.parent.entryFormat & 0x0030) >> 4) + 1),
27
+ outerIndex: t => t.entry >> ((t.parent.entryFormat & 0x000F) + 1),
28
+ innerIndex: t => t.entry & ((1 << ((t.parent.entryFormat & 0x000F) + 1)) - 1)
29
+ });
30
+
31
+ let DeltaSetIndexMap = new r.Struct({
32
+ entryFormat: r.uint16,
33
+ mapCount: r.uint16,
34
+ mapData: new r.Array(MapDataEntry, 'mapCount')
35
+ });
36
+
37
+ export default new r.Struct({
38
+ majorVersion: r.uint16,
39
+ minorVersion: r.uint16,
40
+ itemVariationStore: new r.Pointer(r.uint32, ItemVariationStore),
41
+ advanceWidthMapping: new r.Pointer(r.uint32, DeltaSetIndexMap),
42
+ LSBMapping: new r.Pointer(r.uint32, DeltaSetIndexMap),
43
+ RSBMapping: new r.Pointer(r.uint32, DeltaSetIndexMap)
44
+ });
node_modules/fontkit/src/tables/JSTF.js ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+ import { ScriptList, FeatureList, LookupList, Coverage, ClassDef, Device } from './opentype';
3
+ import { GPOSLookup } from './GPOS';
4
+
5
+ let JstfGSUBModList = new r.Array(r.uint16, r.uint16);
6
+
7
+ let JstfPriority = new r.Struct({
8
+ shrinkageEnableGSUB: new r.Pointer(r.uint16, JstfGSUBModList),
9
+ shrinkageDisableGSUB: new r.Pointer(r.uint16, JstfGSUBModList),
10
+ shrinkageEnableGPOS: new r.Pointer(r.uint16, JstfGSUBModList),
11
+ shrinkageDisableGPOS: new r.Pointer(r.uint16, JstfGSUBModList),
12
+ shrinkageJstfMax: new r.Pointer(r.uint16, new LookupList(GPOSLookup)),
13
+ extensionEnableGSUB: new r.Pointer(r.uint16, JstfGSUBModList),
14
+ extensionDisableGSUB: new r.Pointer(r.uint16, JstfGSUBModList),
15
+ extensionEnableGPOS: new r.Pointer(r.uint16, JstfGSUBModList),
16
+ extensionDisableGPOS: new r.Pointer(r.uint16, JstfGSUBModList),
17
+ extensionJstfMax: new r.Pointer(r.uint16, new LookupList(GPOSLookup))
18
+ });
19
+
20
+ let JstfLangSys = new r.Array(new r.Pointer(r.uint16, JstfPriority), r.uint16);
21
+
22
+ let JstfLangSysRecord = new r.Struct({
23
+ tag: new r.String(4),
24
+ jstfLangSys: new r.Pointer(r.uint16, JstfLangSys)
25
+ });
26
+
27
+ let JstfScript = new r.Struct({
28
+ extenderGlyphs: new r.Pointer(r.uint16, new r.Array(r.uint16, r.uint16)), // array of glyphs to extend line length
29
+ defaultLangSys: new r.Pointer(r.uint16, JstfLangSys),
30
+ langSysCount: r.uint16,
31
+ langSysRecords: new r.Array(JstfLangSysRecord, 'langSysCount')
32
+ });
33
+
34
+ let JstfScriptRecord = new r.Struct({
35
+ tag: new r.String(4),
36
+ script: new r.Pointer(r.uint16, JstfScript, {type: 'parent'})
37
+ });
38
+
39
+ export default new r.Struct({
40
+ version: r.uint32, // should be 0x00010000
41
+ scriptCount: r.uint16,
42
+ scriptList: new r.Array(JstfScriptRecord, 'scriptCount')
43
+ });
node_modules/fontkit/src/tables/LTSH.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ // Linear Threshold table
4
+ // Records the ppem for each glyph at which the scaling becomes linear again,
5
+ // despite instructions effecting the advance width
6
+ export default new r.Struct({
7
+ version: r.uint16,
8
+ numGlyphs: r.uint16,
9
+ yPels: new r.Array(r.uint8, 'numGlyphs')
10
+ });
node_modules/fontkit/src/tables/OS2.js ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ var OS2 = new r.VersionedStruct(r.uint16, {
4
+ header: {
5
+ xAvgCharWidth: r.int16, // average weighted advance width of lower case letters and space
6
+ usWeightClass: r.uint16, // visual weight of stroke in glyphs
7
+ usWidthClass: r.uint16, // relative change from the normal aspect ratio (width to height ratio)
8
+ fsType: new r.Bitfield(r.uint16, [ // Indicates font embedding licensing rights
9
+ null, 'noEmbedding', 'viewOnly', 'editable', null,
10
+ null, null, null, 'noSubsetting', 'bitmapOnly'
11
+ ]),
12
+ ySubscriptXSize: r.int16, // recommended horizontal size in pixels for subscripts
13
+ ySubscriptYSize: r.int16, // recommended vertical size in pixels for subscripts
14
+ ySubscriptXOffset: r.int16, // recommended horizontal offset for subscripts
15
+ ySubscriptYOffset: r.int16, // recommended vertical offset form the baseline for subscripts
16
+ ySuperscriptXSize: r.int16, // recommended horizontal size in pixels for superscripts
17
+ ySuperscriptYSize: r.int16, // recommended vertical size in pixels for superscripts
18
+ ySuperscriptXOffset: r.int16, // recommended horizontal offset for superscripts
19
+ ySuperscriptYOffset: r.int16, // recommended vertical offset from the baseline for superscripts
20
+ yStrikeoutSize: r.int16, // width of the strikeout stroke
21
+ yStrikeoutPosition: r.int16, // position of the strikeout stroke relative to the baseline
22
+ sFamilyClass: r.int16, // classification of font-family design
23
+ panose: new r.Array(r.uint8, 10), // describe the visual characteristics of a given typeface
24
+ ulCharRange: new r.Array(r.uint32, 4),
25
+ vendorID: new r.String(4), // four character identifier for the font vendor
26
+ fsSelection: new r.Bitfield(r.uint16, [ // bit field containing information about the font
27
+ 'italic', 'underscore', 'negative', 'outlined', 'strikeout',
28
+ 'bold', 'regular', 'useTypoMetrics', 'wws', 'oblique'
29
+ ]),
30
+ usFirstCharIndex: r.uint16, // The minimum Unicode index in this font
31
+ usLastCharIndex: r.uint16 // The maximum Unicode index in this font
32
+ },
33
+
34
+ // The Apple version of this table ends here, but the Microsoft one continues on...
35
+ 0: {},
36
+
37
+ 1: {
38
+ typoAscender: r.int16,
39
+ typoDescender: r.int16,
40
+ typoLineGap: r.int16,
41
+ winAscent: r.uint16,
42
+ winDescent: r.uint16,
43
+ codePageRange: new r.Array(r.uint32, 2)
44
+ },
45
+
46
+ 2: {
47
+ // these should be common with version 1 somehow
48
+ typoAscender: r.int16,
49
+ typoDescender: r.int16,
50
+ typoLineGap: r.int16,
51
+ winAscent: r.uint16,
52
+ winDescent: r.uint16,
53
+ codePageRange: new r.Array(r.uint32, 2),
54
+
55
+ xHeight: r.int16,
56
+ capHeight: r.int16,
57
+ defaultChar: r.uint16,
58
+ breakChar: r.uint16,
59
+ maxContent: r.uint16
60
+ },
61
+
62
+ 5: {
63
+ typoAscender: r.int16,
64
+ typoDescender: r.int16,
65
+ typoLineGap: r.int16,
66
+ winAscent: r.uint16,
67
+ winDescent: r.uint16,
68
+ codePageRange: new r.Array(r.uint32, 2),
69
+
70
+ xHeight: r.int16,
71
+ capHeight: r.int16,
72
+ defaultChar: r.uint16,
73
+ breakChar: r.uint16,
74
+ maxContent: r.uint16,
75
+
76
+ usLowerOpticalPointSize: r.uint16,
77
+ usUpperOpticalPointSize: r.uint16
78
+ }
79
+ });
80
+
81
+ let versions = OS2.versions;
82
+ versions[3] = versions[4] = versions[2];
83
+
84
+ export default OS2;
node_modules/fontkit/src/tables/PCLT.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ // PCL 5 Table
4
+ // NOTE: The PCLT table is strongly discouraged for OpenType fonts with TrueType outlines
5
+ export default new r.Struct({
6
+ version: r.uint16,
7
+ fontNumber: r.uint32,
8
+ pitch: r.uint16,
9
+ xHeight: r.uint16,
10
+ style: r.uint16,
11
+ typeFamily: r.uint16,
12
+ capHeight: r.uint16,
13
+ symbolSet: r.uint16,
14
+ typeface: new r.String(16),
15
+ characterComplement: new r.String(8),
16
+ fileName: new r.String(6),
17
+ strokeWeight: new r.String(1),
18
+ widthType: new r.String(1),
19
+ serifStyle: r.uint8,
20
+ reserved: new r.Reserved(r.uint8)
21
+ });
node_modules/fontkit/src/tables/VDMX.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ // VDMX tables contain ascender/descender overrides for certain (usually small)
4
+ // sizes. This is needed in order to match font metrics on Windows.
5
+
6
+ let Ratio = new r.Struct({
7
+ bCharSet: r.uint8, // Character set
8
+ xRatio: r.uint8, // Value to use for x-Ratio
9
+ yStartRatio: r.uint8, // Starting y-Ratio value
10
+ yEndRatio: r.uint8 // Ending y-Ratio value
11
+ });
12
+
13
+ let vTable = new r.Struct({
14
+ yPelHeight: r.uint16, // yPelHeight to which values apply
15
+ yMax: r.int16, // Maximum value (in pels) for this yPelHeight
16
+ yMin: r.int16 // Minimum value (in pels) for this yPelHeight
17
+ });
18
+
19
+ let VdmxGroup = new r.Struct({
20
+ recs: r.uint16, // Number of height records in this group
21
+ startsz: r.uint8, // Starting yPelHeight
22
+ endsz: r.uint8, // Ending yPelHeight
23
+ entries: new r.Array(vTable, 'recs') // The VDMX records
24
+ });
25
+
26
+ export default new r.Struct({
27
+ version: r.uint16, // Version number (0 or 1)
28
+ numRecs: r.uint16, // Number of VDMX groups present
29
+ numRatios: r.uint16, // Number of aspect ratio groupings
30
+ ratioRanges: new r.Array(Ratio, 'numRatios'), // Ratio ranges
31
+ offsets: new r.Array(r.uint16, 'numRatios'), // Offset to the VDMX group for this ratio range
32
+ groups: new r.Array(VdmxGroup, 'numRecs') // The actual VDMX groupings
33
+ });
node_modules/fontkit/src/tables/VORG.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ let VerticalOrigin = new r.Struct({
4
+ glyphIndex: r.uint16,
5
+ vertOriginY: r.int16
6
+ });
7
+
8
+ export default new r.Struct({
9
+ majorVersion: r.uint16,
10
+ minorVersion: r.uint16,
11
+ defaultVertOriginY: r.int16,
12
+ numVertOriginYMetrics: r.uint16,
13
+ metrics: new r.Array(VerticalOrigin, 'numVertOriginYMetrics')
14
+ });
node_modules/fontkit/src/tables/WOFF2Directory.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ const Base128 = {
4
+ decode(stream) {
5
+ let result = 0;
6
+ let iterable = [0, 1, 2, 3, 4];
7
+ for (let j = 0; j < iterable.length; j++) {
8
+ let i = iterable[j];
9
+ let code = stream.readUInt8();
10
+
11
+ // If any of the top seven bits are set then we're about to overflow.
12
+ if (result & 0xe0000000) {
13
+ throw new Error('Overflow');
14
+ }
15
+
16
+ result = (result << 7) | (code & 0x7f);
17
+ if ((code & 0x80) === 0) {
18
+ return result;
19
+ }
20
+ }
21
+
22
+ throw new Error('Bad base 128 number');
23
+ }
24
+ };
25
+
26
+ let knownTags = [
27
+ 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'OS/2', 'post', 'cvt ',
28
+ 'fpgm', 'glyf', 'loca', 'prep', 'CFF ', 'VORG', 'EBDT', 'EBLC', 'gasp',
29
+ 'hdmx', 'kern', 'LTSH', 'PCLT', 'VDMX', 'vhea', 'vmtx', 'BASE', 'GDEF',
30
+ 'GPOS', 'GSUB', 'EBSC', 'JSTF', 'MATH', 'CBDT', 'CBLC', 'COLR', 'CPAL',
31
+ 'SVG ', 'sbix', 'acnt', 'avar', 'bdat', 'bloc', 'bsln', 'cvar', 'fdsc',
32
+ 'feat', 'fmtx', 'fvar', 'gvar', 'hsty', 'just', 'lcar', 'mort', 'morx',
33
+ 'opbd', 'prop', 'trak', 'Zapf', 'Silf', 'Glat', 'Gloc', 'Feat', 'Sill'
34
+ ];
35
+
36
+ let WOFF2DirectoryEntry = new r.Struct({
37
+ flags: r.uint8,
38
+ customTag: new r.Optional(new r.String(4), t => (t.flags & 0x3f) === 0x3f),
39
+ tag: t => t.customTag || knownTags[t.flags & 0x3f],// || (() => { throw new Error(`Bad tag: ${flags & 0x3f}`); })(); },
40
+ length: Base128,
41
+ transformVersion: t => (t.flags >>> 6) & 0x03,
42
+ transformed: t => (t.tag === 'glyf' || t.tag === 'loca') ? t.transformVersion === 0 : t.transformVersion !== 0,
43
+ transformLength: new r.Optional(Base128, t => t.transformed)
44
+ });
45
+
46
+ let WOFF2Directory = new r.Struct({
47
+ tag: new r.String(4), // should be 'wOF2'
48
+ flavor: r.uint32,
49
+ length: r.uint32,
50
+ numTables: r.uint16,
51
+ reserved: new r.Reserved(r.uint16),
52
+ totalSfntSize: r.uint32,
53
+ totalCompressedSize: r.uint32,
54
+ majorVersion: r.uint16,
55
+ minorVersion: r.uint16,
56
+ metaOffset: r.uint32,
57
+ metaLength: r.uint32,
58
+ metaOrigLength: r.uint32,
59
+ privOffset: r.uint32,
60
+ privLength: r.uint32,
61
+ tables: new r.Array(WOFF2DirectoryEntry, 'numTables')
62
+ });
63
+
64
+ WOFF2Directory.process = function() {
65
+ let tables = {};
66
+ for (let i = 0; i < this.tables.length; i++) {
67
+ let table = this.tables[i];
68
+ tables[table.tag] = table;
69
+ }
70
+
71
+ return this.tables = tables;
72
+ };
73
+
74
+ export default WOFF2Directory;
node_modules/fontkit/src/tables/WOFFDirectory.js ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+ import tables from './';
3
+
4
+ let WOFFDirectoryEntry = new r.Struct({
5
+ tag: new r.String(4),
6
+ offset: new r.Pointer(r.uint32, 'void', {type: 'global'}),
7
+ compLength: r.uint32,
8
+ length: r.uint32,
9
+ origChecksum: r.uint32
10
+ });
11
+
12
+ let WOFFDirectory = new r.Struct({
13
+ tag: new r.String(4), // should be 'wOFF'
14
+ flavor: r.uint32,
15
+ length: r.uint32,
16
+ numTables: r.uint16,
17
+ reserved: new r.Reserved(r.uint16),
18
+ totalSfntSize: r.uint32,
19
+ majorVersion: r.uint16,
20
+ minorVersion: r.uint16,
21
+ metaOffset: r.uint32,
22
+ metaLength: r.uint32,
23
+ metaOrigLength: r.uint32,
24
+ privOffset: r.uint32,
25
+ privLength: r.uint32,
26
+ tables: new r.Array(WOFFDirectoryEntry, 'numTables')
27
+ });
28
+
29
+ WOFFDirectory.process = function() {
30
+ let tables = {};
31
+ for (let table of this.tables) {
32
+ tables[table.tag] = table;
33
+ }
34
+
35
+ this.tables = tables;
36
+ };
37
+
38
+ export default WOFFDirectory;
node_modules/fontkit/src/tables/aat.js ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as r from 'restructure';
2
+
3
+ class UnboundedArrayAccessor {
4
+ constructor(type, stream, parent) {
5
+ this.type = type;
6
+ this.stream = stream;
7
+ this.parent = parent;
8
+ this.base = this.stream.pos;
9
+ this._items = [];
10
+ }
11
+
12
+ getItem(index) {
13
+ if (this._items[index] == null) {
14
+ let pos = this.stream.pos;
15
+ this.stream.pos = this.base + this.type.size(null, this.parent) * index;
16
+ this._items[index] = this.type.decode(this.stream, this.parent);
17
+ this.stream.pos = pos;
18
+ }
19
+
20
+ return this._items[index];
21
+ }
22
+
23
+ inspect() {
24
+ return `[UnboundedArray ${this.type.constructor.name}]`;
25
+ }
26
+ }
27
+
28
+ export class UnboundedArray extends r.Array {
29
+ constructor(type) {
30
+ super(type, 0);
31
+ }
32
+
33
+ decode(stream, parent) {
34
+ return new UnboundedArrayAccessor(this.type, stream, parent);
35
+ }
36
+ }
37
+
38
+ export let LookupTable = function(ValueType = r.uint16) {
39
+ // Helper class that makes internal structures invisible to pointers
40
+ class Shadow {
41
+ constructor(type) {
42
+ this.type = type;
43
+ }
44
+
45
+ decode(stream, ctx) {
46
+ ctx = ctx.parent.parent;
47
+ return this.type.decode(stream, ctx);
48
+ }
49
+
50
+ size(val, ctx) {
51
+ ctx = ctx.parent.parent;
52
+ return this.type.size(val, ctx);
53
+ }
54
+
55
+ encode(stream, val, ctx) {
56
+ ctx = ctx.parent.parent;
57
+ return this.type.encode(stream, val, ctx);
58
+ }
59
+ }
60
+
61
+ ValueType = new Shadow(ValueType);
62
+
63
+ let BinarySearchHeader = new r.Struct({
64
+ unitSize: r.uint16,
65
+ nUnits: r.uint16,
66
+ searchRange: r.uint16,
67
+ entrySelector: r.uint16,
68
+ rangeShift: r.uint16
69
+ });
70
+
71
+ let LookupSegmentSingle = new r.Struct({
72
+ lastGlyph: r.uint16,
73
+ firstGlyph: r.uint16,
74
+ value: ValueType
75
+ });
76
+
77
+ let LookupSegmentArray = new r.Struct({
78
+ lastGlyph: r.uint16,
79
+ firstGlyph: r.uint16,
80
+ values: new r.Pointer(r.uint16, new r.Array(ValueType, t => t.lastGlyph - t.firstGlyph + 1), {type: 'parent'})
81
+ });
82
+
83
+ let LookupSingle = new r.Struct({
84
+ glyph: r.uint16,
85
+ value: ValueType
86
+ });
87
+
88
+ return new r.VersionedStruct(r.uint16, {
89
+ 0: {
90
+ values: new UnboundedArray(ValueType) // length == number of glyphs maybe?
91
+ },
92
+ 2: {
93
+ binarySearchHeader: BinarySearchHeader,
94
+ segments: new r.Array(LookupSegmentSingle, t => t.binarySearchHeader.nUnits)
95
+ },
96
+ 4: {
97
+ binarySearchHeader: BinarySearchHeader,
98
+ segments: new r.Array(LookupSegmentArray, t => t.binarySearchHeader.nUnits)
99
+ },
100
+ 6: {
101
+ binarySearchHeader: BinarySearchHeader,
102
+ segments: new r.Array(LookupSingle, t => t.binarySearchHeader.nUnits)
103
+ },
104
+ 8: {
105
+ firstGlyph: r.uint16,
106
+ count: r.uint16,
107
+ values: new r.Array(ValueType, 'count')
108
+ }
109
+ });
110
+ };
111
+
112
+ export function StateTable(entryData = {}, lookupType = r.uint16) {
113
+ let entry = Object.assign({
114
+ newState: r.uint16,
115
+ flags: r.uint16
116
+ }, entryData);
117
+
118
+ let Entry = new r.Struct(entry);
119
+ let StateArray = new UnboundedArray(new r.Array(r.uint16, t => t.nClasses));
120
+
121
+ let StateHeader = new r.Struct({
122
+ nClasses: r.uint32,
123
+ classTable: new r.Pointer(r.uint32, new LookupTable(lookupType)),
124
+ stateArray: new r.Pointer(r.uint32, StateArray),
125
+ entryTable: new r.Pointer(r.uint32, new UnboundedArray(Entry))
126
+ });
127
+
128
+ return StateHeader;
129
+ }
130
+
131
+ // This is the old version of the StateTable structure
132
+ export function StateTable1(entryData = {}, lookupType = r.uint16) {
133
+ let ClassLookupTable = new r.Struct({
134
+ version() { return 8; }, // simulate LookupTable
135
+ firstGlyph: r.uint16,
136
+ values: new r.Array(r.uint8, r.uint16)
137
+ });
138
+
139
+ let entry = Object.assign({
140
+ newStateOffset: r.uint16,
141
+ // convert offset to stateArray index
142
+ newState: t => (t.newStateOffset - (t.parent.stateArray.base - t.parent._startOffset)) / t.parent.nClasses,
143
+ flags: r.uint16
144
+ }, entryData);
145
+
146
+ let Entry = new r.Struct(entry);
147
+ let StateArray = new UnboundedArray(new r.Array(r.uint8, t => t.nClasses));
148
+
149
+ let StateHeader1 = new r.Struct({
150
+ nClasses: r.uint16,
151
+ classTable: new r.Pointer(r.uint16, ClassLookupTable),
152
+ stateArray: new r.Pointer(r.uint16, StateArray),
153
+ entryTable: new r.Pointer(r.uint16, new UnboundedArray(Entry))
154
+ });
155
+
156
+ return StateHeader1;
157
+ }