@syncfusion/ej2-pdf-data-extract 35.1.41 → 35.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1380 @@
1
+ /**
2
+ * Utilities for converting visually ordered RTL text (as stored inside PDF content
3
+ * streams) into logical Unicode reading order, and for normalizing Arabic
4
+ * presentation forms back to their base Unicode code points.
5
+ *
6
+ * @private
7
+ */
8
+ /**
9
+ * Checks whether the character is an Arabic presentation form (isolated, final,
10
+ * initial or medial shape) in the Arabic Presentation Forms A/B blocks.
11
+ *
12
+ * @param {string} ch - Character to check.
13
+ * @returns {boolean} True when the character is an Arabic presentation form.
14
+ * @private
15
+ */
16
+ export function _isArabicPresentationForm(ch) {
17
+ var code = ch.charCodeAt(0);
18
+ return (code >= 0xFB50 && code <= 0xFDFF) || (code >= 0xFE70 && code <= 0xFEFF);
19
+ }
20
+ /**
21
+ * Checks whether the character belongs to a right-to-left script (Arabic, Hebrew,
22
+ * Syriac, Thaana and related presentation blocks).
23
+ *
24
+ * @param {string} ch - Character to check.
25
+ * @returns {boolean} True when the character is an RTL character.
26
+ * @private
27
+ */
28
+ export function _isRtlCharacter(ch) {
29
+ var code = ch.charCodeAt(0);
30
+ if (code < 0x0590 || code > 0x08FF) {
31
+ if (code < 0xFB1D || code > 0xFEFF) {
32
+ return false;
33
+ }
34
+ }
35
+ if (code >= 0x0600 && code <= 0x0605) {
36
+ return false;
37
+ }
38
+ if (code >= 0x0660 && code <= 0x0669) {
39
+ return false;
40
+ }
41
+ if (code >= 0x06F0 && code <= 0x06F9) {
42
+ return false;
43
+ }
44
+ if (code >= 0x064B && code <= 0x065F) {
45
+ return false;
46
+ }
47
+ if (code === 0x0640) {
48
+ return false;
49
+ }
50
+ return true;
51
+ }
52
+ /**
53
+ * Checks whether the character is a neutral character (space, punctuation) that
54
+ * takes its direction from surrounding strong characters.
55
+ *
56
+ * @param {string} ch - Character to check.
57
+ * @returns {boolean} True when the character is directionally neutral.
58
+ * @private
59
+ */
60
+ export function _isNeutralCharacter(ch) {
61
+ var code = ch.charCodeAt(0);
62
+ if (code < 0x20) {
63
+ return true;
64
+ }
65
+ if (code === 0x20 || code === 0xA0) {
66
+ return true;
67
+ }
68
+ if (code >= 0x2000 && code <= 0x200F) {
69
+ return true;
70
+ }
71
+ if (code >= 0x060C && code <= 0x060C) {
72
+ return true;
73
+ }
74
+ if (code === 0x061B || code === 0x061F || code === 0x06D4) {
75
+ return true;
76
+ }
77
+ if (code >= 0x066A && code <= 0x066D) {
78
+ return true;
79
+ }
80
+ if (code >= 0x21 && code <= 0x2F) {
81
+ return true;
82
+ }
83
+ if (code >= 0x3A && code <= 0x3F) {
84
+ return true;
85
+ }
86
+ if (code >= 0x5B && code <= 0x60) {
87
+ return true;
88
+ }
89
+ if (code >= 0x7B && code <= 0x7E) {
90
+ return true;
91
+ }
92
+ if (code === 0x2013 || code === 0x2014 || code === 0x2026 || code === 0xAB || code === 0xBB) {
93
+ return true;
94
+ }
95
+ return false;
96
+ }
97
+ /**
98
+ * Checks whether the character is a left-to-right character (Latin letters,
99
+ * digits and other common LTR characters).
100
+ *
101
+ * @param {string} ch - Character to check.
102
+ * @returns {boolean} True when the character is an LTR character.
103
+ * @private
104
+ */
105
+ export function _isLtrCharacter(ch) {
106
+ var code = ch.charCodeAt(0);
107
+ if (code >= 0x41 && code <= 0x5A) {
108
+ return true;
109
+ }
110
+ if (code >= 0x61 && code <= 0x7A) {
111
+ return true;
112
+ }
113
+ if (code >= 0x30 && code <= 0x39) {
114
+ return true;
115
+ }
116
+ if (code >= 0x0660 && code <= 0x0669) {
117
+ return true;
118
+ }
119
+ if (code >= 0x06F0 && code <= 0x06F9) {
120
+ return true;
121
+ }
122
+ return (code >= 0xC0 && code <= 0x24F) && !((code >= 0x0590 && code <= 0x08FF));
123
+ }
124
+ /**
125
+ * Maps Arabic presentation form characters (U+FB50–U+FDFF, U+FE70–U+FEFF) to their
126
+ * base Arabic code points (U+0600–U+06FF and supplement ranges). Ligature
127
+ * presentation forms are mapped to their multi-character logical equivalents.
128
+ *
129
+ * @param {string} ch - Character to normalize.
130
+ * @returns {string} The base (logical) Unicode representation of the character.
131
+ * @private
132
+ */
133
+ export function _normalizeArabicCharacter(ch) {
134
+ var code = ch.charCodeAt(0);
135
+ var mapped = Object.prototype.hasOwnProperty.call(arabicPresentationForms, code)
136
+ ? arabicPresentationForms[code] : undefined;
137
+ if (typeof (mapped) === 'string') {
138
+ return mapped;
139
+ }
140
+ return ch;
141
+ }
142
+ /**
143
+ * Reverses a copy of the given array between the specified bounds (inclusive).
144
+ *
145
+ * @param {string[]} items - Array to reverse a portion of.
146
+ * @param {number} start - Start index.
147
+ * @param {number} end - End index (inclusive).
148
+ * @returns {void}
149
+ * @private
150
+ */
151
+ function _reverseRange(items, start, end) {
152
+ while (start < end) {
153
+ var temp = items[start];
154
+ items[start] = items[end];
155
+ items[end] = temp;
156
+ start++;
157
+ end--;
158
+ }
159
+ }
160
+ /**
161
+ * Converts visually ordered text containing RTL content into logical Unicode order.
162
+ * LTR runs are left untouched, so mixed RTL/LTR text is preserved. Characters are
163
+ * handled as UTF-16 code units to match the rest of the extraction pipeline.
164
+ *
165
+ * @param {string} text - Text in visual order as extracted from the PDF content stream.
166
+ * @returns {string} Text in logical reading order.
167
+ * @private
168
+ */
169
+ export function _convertVisualToLogicalOrder(text) {
170
+ if (typeof (text) !== 'string' || text.length === 0) {
171
+ return text;
172
+ }
173
+ if (text.indexOf('\r') !== -1 || text.indexOf('\n') !== -1) {
174
+ var lines = text.split(/(\r\n|\r|\n)/);
175
+ var result = '';
176
+ for (var i = 0; i < lines.length; i++) {
177
+ var part = lines[Number.parseInt(i.toString(), 10)];
178
+ if (part === '\r\n' || part === '\r' || part === '\n') {
179
+ result += part;
180
+ }
181
+ else {
182
+ result += _convertVisualToLogicalOrder(part);
183
+ }
184
+ }
185
+ return result;
186
+ }
187
+ var characters = [];
188
+ for (var i = 0; i < text.length; i++) {
189
+ characters.push(text[Number.parseInt(i.toString(), 10)]);
190
+ }
191
+ if (!_containsRtlCharacter(text)) {
192
+ return characters.join('');
193
+ }
194
+ var length = characters.length;
195
+ _reverseRange(characters, 0, length - 1);
196
+ if (_isWholeLineReversalStorage(text)) {
197
+ return characters.join('');
198
+ }
199
+ var index = 0;
200
+ while (index < length) {
201
+ var character = characters[Number.parseInt(index.toString(), 10)];
202
+ if (!_isRtlCharacter(character) && !_isNeutralCharacter(character)) {
203
+ var runEnd = index;
204
+ for (var j = index + 1; j < length; j++) {
205
+ var next = characters[Number.parseInt(j.toString(), 10)];
206
+ if (_isRtlCharacter(next)) {
207
+ break;
208
+ }
209
+ if (_isNeutralCharacter(next)) {
210
+ var after = j + 1;
211
+ while (after < length && _isNeutralCharacter(characters[Number.parseInt(after.toString(), 10)])) {
212
+ after++;
213
+ }
214
+ if (after < length && !_isRtlCharacter(characters[Number.parseInt(after.toString(), 10)])) {
215
+ runEnd = after - 1;
216
+ j = after - 1;
217
+ }
218
+ else {
219
+ break;
220
+ }
221
+ }
222
+ else {
223
+ runEnd = j;
224
+ }
225
+ }
226
+ _reverseRange(characters, index, runEnd);
227
+ index = runEnd + 1;
228
+ }
229
+ else {
230
+ index++;
231
+ }
232
+ }
233
+ return characters.join('');
234
+ }
235
+ /**
236
+ * Mirrored (swapped) forms of the paired bracket characters. RTL visual
237
+ * layout stores these glyphs mirrored (Unicode BiDi rule L4), so converting
238
+ * a visual fragment back to logical order must swap the pair members.
239
+ *
240
+ * @private
241
+ */
242
+ var mirroredBrackets = {
243
+ '(': ')', ')': '(',
244
+ '[': ']', ']': '[',
245
+ '{': '}', '}': '{',
246
+ '\u00AB': '\u00BB', '\u00BB': '\u00AB'
247
+ };
248
+ /**
249
+ * Swaps mirrored paired bracket characters (parentheses, square brackets, curly
250
+ * braces, angle quotes) back to their logical pair member. RTL visual layout
251
+ * paints these glyphs mirrored (Unicode BiDi rule L4), so a visual-order line
252
+ * must be un-mirrored to yield the logical text Adobe extracts.
253
+ *
254
+ * @param {string} text - Text containing mirrored bracket glyphs.
255
+ * @returns {string} Text with pair members swapped back.
256
+ * @private
257
+ */
258
+ export function _unmirrorPairedBrackets(text) {
259
+ if (typeof (text) !== 'string' || text.length === 0) {
260
+ return text;
261
+ }
262
+ var result = '';
263
+ for (var i = 0; i < text.length; i++) {
264
+ var ch = text[Number.parseInt(i.toString(), 10)];
265
+ if (Object.prototype.hasOwnProperty.call(mirroredBrackets, ch)) {
266
+ result += mirroredBrackets[ch]; // eslint-disable-line
267
+ }
268
+ else {
269
+ result += ch;
270
+ }
271
+ }
272
+ return result;
273
+ }
274
+ /**
275
+ * Converts a visual-order fragment that contains no RTL characters (Latin
276
+ * tokens, digits, neutral punctuation) into logical order for an RTL line.
277
+ *
278
+ * @param {string} text - Fragment in visual order.
279
+ * @returns {string} Fragment in logical order (bracket glyphs unchanged).
280
+ * @private
281
+ */
282
+ export function _invertVisualLtrFragment(text) {
283
+ if (typeof (text) !== 'string' || text.length === 0) {
284
+ return text;
285
+ }
286
+ var characters = text.split('');
287
+ _reverseRange(characters, 0, characters.length - 1);
288
+ var index = 0;
289
+ while (index < characters.length) {
290
+ if (_isLtrCharacter(characters[Number.parseInt(index.toString(), 10)])) {
291
+ var runEnd = index;
292
+ while (runEnd + 1 < characters.length &&
293
+ _isLtrCharacter(characters[Number.parseInt((runEnd + 1).toString(), 10)])) {
294
+ runEnd++;
295
+ }
296
+ _reverseRange(characters, index, runEnd);
297
+ index = runEnd + 1;
298
+ }
299
+ else {
300
+ index++;
301
+ }
302
+ }
303
+ return characters.join('');
304
+ }
305
+ /**
306
+ * Checks whether the paired brackets in the given text form a balanced
307
+ * sequence (every closing bracket is preceded by a matching opener and no
308
+ * depth underflow). Text without brackets is balanced by definition.
309
+ *
310
+ * @param {string} text - Text to inspect.
311
+ * @returns {boolean} True when the bracket sequence is balanced.
312
+ * @private
313
+ */
314
+ function _isBracketSequenceBalanced(text) {
315
+ if (typeof (text) !== 'string' || text.length === 0) {
316
+ return true;
317
+ }
318
+ var openers = { '(': ')', '[': ']', '{': '}', '\u00AB': '\u00BB' };
319
+ var closers = { ')': '(', ']': '[', '}': '{', '\u00BB': '\u00AB' };
320
+ var stack = [];
321
+ for (var i = 0; i < text.length; i++) {
322
+ var ch = text[Number.parseInt(i.toString(), 10)];
323
+ if (Object.prototype.hasOwnProperty.call(openers, ch)) {
324
+ stack.push(openers[ch]); // eslint-disable-line
325
+ }
326
+ else if (Object.prototype.hasOwnProperty.call(closers, ch)) {
327
+ var expected = stack.length > 0 ? stack.pop() : undefined;
328
+ if (expected !== undefined && expected !== ch) {
329
+ return false;
330
+ }
331
+ if (expected === undefined) {
332
+ return false;
333
+ }
334
+ }
335
+ }
336
+ return stack.length === 0;
337
+ }
338
+ /**
339
+ * Resolves paired-bracket glyph mirroring for a logical-order RTL line.
340
+ *
341
+ * @param {string} text - Line text in logical order.
342
+ * @returns {string} Text with mirrored bracket glyphs restored when needed.
343
+ * @private
344
+ */
345
+ export function _resolveMirroredBrackets(text) {
346
+ if (typeof (text) !== 'string' || text.length === 0) {
347
+ return text;
348
+ }
349
+ if (_isBracketSequenceBalanced(text)) {
350
+ return text;
351
+ }
352
+ var unmirrored = _unmirrorPairedBrackets(text);
353
+ return _isBracketSequenceBalanced(unmirrored) ? unmirrored : text;
354
+ }
355
+ /**
356
+ * Detects the naive whole-line-reversal storage convention using digit runs
357
+ * embedded in RTL text. In canonical visual storage digit runs read
358
+ * left-to-right in ascending significance order ("2010"); if a stored digit
359
+ * run instead reads like a plain reversal of an ascending run ("0102"), the
360
+ * producer wrote the whole logical string reversed (convention B).
361
+ *
362
+ * @param {string} text - Text in visual order as extracted from the PDF.
363
+ * @returns {boolean} True when the text appears whole-line-reversal stored.
364
+ * @private
365
+ */
366
+ function _isWholeLineReversalStorage(text) {
367
+ var runs = [];
368
+ var current = '';
369
+ for (var i = 0; i < text.length; i++) {
370
+ var code = text.charCodeAt(i);
371
+ var isDigit = (code >= 0x30 && code <= 0x39) || (code >= 0x0660 && code <= 0x0669);
372
+ if (isDigit) {
373
+ current += text[i];
374
+ }
375
+ else if (current.length > 0) {
376
+ runs.push(current);
377
+ current = '';
378
+ }
379
+ }
380
+ if (current.length > 0) {
381
+ runs.push(current);
382
+ }
383
+ var reversedCount = 0;
384
+ var total = 0;
385
+ for (var i = 0; i < runs.length; i++) {
386
+ var run = runs[Number.parseInt(i.toString(), 10)];
387
+ if (run.length < 2) {
388
+ continue;
389
+ }
390
+ total++;
391
+ if (run === run.split('').reverse().join('')) {
392
+ if (run.length >= 2 && new Set(run).size === 1) {
393
+ total--;
394
+ }
395
+ continue;
396
+ }
397
+ if (run[0] === '0' || run[0] === String.fromCharCode(0x0660)) {
398
+ reversedCount++;
399
+ }
400
+ }
401
+ if (total === 0) {
402
+ return false;
403
+ }
404
+ return reversedCount / total >= 0.5;
405
+ }
406
+ /**
407
+ * Converts visually ordered RTL text into logical order and normalizes Arabic
408
+ * presentation forms to their base Unicode code points. This produces text
409
+ * comparable to Adobe text extraction for Arabic, Hebrew, Persian and Urdu.
410
+ *
411
+ * @param {string} text - Text in visual order as extracted from the PDF.
412
+ * @returns {string} Normalized text in logical reading order.
413
+ * @private
414
+ */
415
+ export function _normalizeRtlText(text) {
416
+ if (typeof (text) !== 'string' || text.length === 0) {
417
+ return text;
418
+ }
419
+ var reordered = _convertVisualToLogicalOrder(text);
420
+ if (!_containsRtlCharacter(reordered)) {
421
+ return reordered;
422
+ }
423
+ var normalized = '';
424
+ for (var i = 0; i < reordered.length; i++) {
425
+ normalized += _normalizeArabicCharacter(reordered[Number.parseInt(i.toString(), 10)]);
426
+ }
427
+ return normalized;
428
+ }
429
+ /**
430
+ * Checks whether the given string contains any RTL script character.
431
+ *
432
+ * @param {string} text - Text to inspect.
433
+ * @returns {boolean} True when the text contains an RTL character.
434
+ * @private
435
+ */
436
+ export function _containsRtlCharacter(text) {
437
+ if (typeof (text) !== 'string') {
438
+ return false;
439
+ }
440
+ for (var i = 0; i < text.length; i++) {
441
+ if (_isRtlCharacter(text[Number.parseInt(i.toString(), 10)])) {
442
+ return true;
443
+ }
444
+ }
445
+ return false;
446
+ }
447
+ /**
448
+ * Checks whether the given text contains at least one Arabic presentation form
449
+ * character. Producers that store text in visual glyph order typically emit
450
+ * presentation forms, so this is used as a visual-order signal.
451
+ *
452
+ * @param {string} text - Text to inspect.
453
+ * @returns {boolean} True when a presentation form character is present.
454
+ * @private
455
+ */
456
+ export function _containsArabicPresentationForm(text) {
457
+ if (typeof (text) !== 'string') {
458
+ return false;
459
+ }
460
+ for (var i = 0; i < text.length; i++) {
461
+ if (_isArabicPresentationForm(text[Number.parseInt(i.toString(), 10)])) {
462
+ return true;
463
+ }
464
+ }
465
+ return false;
466
+ }
467
+ /**
468
+ * Maps Arabic presentation form characters in the given text to their base
469
+ * Unicode code points WITHOUT any reordering. Used when the text is already
470
+ * in logical order and only character normalization is needed.
471
+ *
472
+ * @param {string} text - Text to map.
473
+ * @returns {string} Text with presentation forms replaced by base characters.
474
+ * @private
475
+ */
476
+ export function _mapArabicPresentationForms(text) {
477
+ if (typeof (text) !== 'string' || text.length === 0) {
478
+ return text;
479
+ }
480
+ if (!_containsRtlCharacter(text)) {
481
+ return text;
482
+ }
483
+ var mapped = '';
484
+ for (var i = 0; i < text.length; i++) {
485
+ var ch = text[Number.parseInt(i.toString(), 10)];
486
+ if (_isArabicPresentationForm(ch)) {
487
+ mapped += _normalizeArabicCharacter(ch);
488
+ }
489
+ else {
490
+ mapped += ch;
491
+ }
492
+ }
493
+ return mapped;
494
+ }
495
+ /**
496
+ * Determines whether the given RTL text is stored in visual (right-to-left
497
+ * glyph) order rather than logical order, using the horizontal position of
498
+ * consecutive glyphs/words. When the second fragment is placed to the RIGHT of
499
+ * the first fragment, the text advances leftward and is visual-ordered RTL.
500
+ *
501
+ * @param {{ x: number, width: number }} firstBounds - Bounds of the earlier extracted fragment.
502
+ * @param {number} firstBounds.x - X-coordinate of the first fragment.
503
+ * @param {number} firstBounds.width - Width of the first fragment.
504
+ * @param {{ x: number, width: number }} secondBounds - Bounds of the next extracted fragment.
505
+ * @param {number} secondBounds.x - X-coordinate of the second fragment.
506
+ * @param {number} secondBounds.width - Width of the second fragment.
507
+ * @returns {boolean} True when the fragments indicate visual RTL ordering.
508
+ * @private
509
+ */
510
+ export function _isVisualOrderRtl(firstBounds, secondBounds) {
511
+ if (!firstBounds || !secondBounds) {
512
+ return false;
513
+ }
514
+ return secondBounds.x > firstBounds.x + firstBounds.width * 0.5;
515
+ }
516
+ /**
517
+ * Normalizes a search input string for comparison. Search input is expected in
518
+ * logical order; Arabic presentation forms are mapped to base code points so a
519
+ * search value typed in logical Arabic matches extracted logical text.
520
+ *
521
+ * @param {string} text - Search text to normalize.
522
+ * @returns {string} Normalized search text.
523
+ * @private
524
+ */
525
+ export function _normalizeSearchText(text) {
526
+ if (typeof (text) !== 'string' || text.length === 0) {
527
+ return text;
528
+ }
529
+ if (!_containsRtlCharacter(text)) {
530
+ return text;
531
+ }
532
+ var normalized = '';
533
+ for (var i = 0; i < text.length; i++) {
534
+ var ch = text[Number.parseInt(i.toString(), 10)];
535
+ if (_isArabicPresentationForm(ch)) {
536
+ normalized += _normalizeArabicCharacter(ch);
537
+ }
538
+ else {
539
+ normalized += ch;
540
+ }
541
+ }
542
+ return normalized;
543
+ }
544
+ /**
545
+ * Rebuilds reading order for extracted fragments: groups fragments that share
546
+ * the same baseline (row) and, for rows containing RTL content, emits the
547
+ * right-most fragment first (Adobe-style RTL line reconstruction). LTR-only
548
+ * rows keep the original (left-to-right) order.
549
+ *
550
+ * @param {_TextFragment[]} fragments - Fragments in content stream order.
551
+ * @returns {_TextFragment[]} Fragments in reading order.
552
+ * @private
553
+ */
554
+ export function _reorderFragmentsForRtlReading(fragments) {
555
+ if (!fragments || fragments.length < 2) {
556
+ return fragments;
557
+ }
558
+ var hasRtl = false;
559
+ for (var i = 0; i < fragments.length; i++) {
560
+ var fragment = fragments[Number.parseInt(i.toString(), 10)];
561
+ if (fragment && _containsRtlCharacter(fragment.text)) {
562
+ hasRtl = true;
563
+ break;
564
+ }
565
+ }
566
+ if (!hasRtl) {
567
+ return fragments;
568
+ }
569
+ var tolerance = _getRtlRowTolerance(fragments);
570
+ var rows = [];
571
+ for (var i = 0; i < fragments.length; i++) {
572
+ var fragment = fragments[Number.parseInt(i.toString(), 10)];
573
+ if (!fragment || !fragment.bounds) {
574
+ continue;
575
+ }
576
+ var placed = false;
577
+ for (var r = 0; r < rows.length; r++) {
578
+ var row = rows[Number.parseInt(r.toString(), 10)];
579
+ var reference = row[0];
580
+ if (_isSameRtlRow(reference.bounds, fragment.bounds, tolerance)) {
581
+ row.push(fragment);
582
+ placed = true;
583
+ break;
584
+ }
585
+ }
586
+ if (!placed) {
587
+ rows.push([fragment]);
588
+ }
589
+ }
590
+ var ordered = [];
591
+ rows.sort(function (a, b) { return a[0].bounds.y - b[0].bounds.y; });
592
+ for (var r = 0; r < rows.length; r++) {
593
+ var row = rows[Number.parseInt(r.toString(), 10)];
594
+ var rowHasRtl = row.some(function (fragment) { return _containsRtlCharacter(fragment.text); });
595
+ if (rowHasRtl) {
596
+ row.sort(function (a, b) { return b.bounds.x - a.bounds.x; });
597
+ }
598
+ else {
599
+ row.sort(function (a, b) { return a.bounds.x - b.bounds.x; });
600
+ }
601
+ for (var i = 0; i < row.length; i++) {
602
+ ordered.push(row[Number.parseInt(i.toString(), 10)]);
603
+ }
604
+ }
605
+ return ordered;
606
+ }
607
+ /**
608
+ * Computes the vertical tolerance used to decide whether two fragments share
609
+ * the same text row (fraction of the dominant fragment height).
610
+ *
611
+ * @param {_TextFragment[]} fragments - Fragments being grouped.
612
+ * @returns {number} Row-grouping tolerance in page units.
613
+ * @private
614
+ */
615
+ function _getRtlRowTolerance(fragments) {
616
+ var totalHeight = 0;
617
+ var count = 0;
618
+ for (var i = 0; i < fragments.length; i++) {
619
+ var fragment = fragments[Number.parseInt(i.toString(), 10)];
620
+ if (fragment && fragment.bounds && fragment.bounds.height > 0) {
621
+ totalHeight += fragment.bounds.height;
622
+ count++;
623
+ }
624
+ }
625
+ if (count === 0) {
626
+ return 2;
627
+ }
628
+ return Math.max(2, (totalHeight / count) * 0.5);
629
+ }
630
+ /**
631
+ * Determines whether two fragment bounds belong to the same text row.
632
+ *
633
+ * @param {{ y: number, height: number }} first - First fragment bounds.
634
+ * @param {number} first.y - Y-coordinate of the first fragment.
635
+ * @param {number} first.height - Height of the first fragment.
636
+ * @param {{ y: number, height: number }} second - Second fragment bounds.
637
+ * @param {number} second.y - Y-coordinate of the second fragment.
638
+ * @param {number} second.height - Height of the second fragment.
639
+ * @param {number} tolerance - Vertical tolerance for row grouping.
640
+ * @returns {boolean} True when both fragments are on the same row.
641
+ * @private
642
+ */
643
+ function _isSameRtlRow(first, second, tolerance) {
644
+ var firstCenter = first.y + first.height / 2;
645
+ var secondCenter = second.y + second.height / 2;
646
+ return Math.abs(firstCenter - secondCenter) <= tolerance;
647
+ }
648
+ var arabicPresentationForms = {
649
+ 0xFB50: '\u0671',
650
+ 0xFB51: '\u0671',
651
+ 0xFB52: '\u067b',
652
+ 0xFB53: '\u067b',
653
+ 0xFB54: '\u067b',
654
+ 0xFB55: '\u067b',
655
+ 0xFB56: '\u067e',
656
+ 0xFB57: '\u067e',
657
+ 0xFB58: '\u067e',
658
+ 0xFB59: '\u067e',
659
+ 0xFB5A: '\u0680',
660
+ 0xFB5B: '\u0680',
661
+ 0xFB5C: '\u0680',
662
+ 0xFB5D: '\u0680',
663
+ 0xFB5E: '\u067a',
664
+ 0xFB5F: '\u067a',
665
+ 0xFB60: '\u067a',
666
+ 0xFB61: '\u067a',
667
+ 0xFB62: '\u067f',
668
+ 0xFB63: '\u067f',
669
+ 0xFB64: '\u067f',
670
+ 0xFB65: '\u067f',
671
+ 0xFB66: '\u0679',
672
+ 0xFB67: '\u0679',
673
+ 0xFB68: '\u0679',
674
+ 0xFB69: '\u0679',
675
+ 0xFB6A: '\u06a4',
676
+ 0xFB6B: '\u06a4',
677
+ 0xFB6C: '\u06a4',
678
+ 0xFB6D: '\u06a4',
679
+ 0xFB6E: '\u06a6',
680
+ 0xFB6F: '\u06a6',
681
+ 0xFB70: '\u06a6',
682
+ 0xFB71: '\u06a6',
683
+ 0xFB72: '\u0684',
684
+ 0xFB73: '\u0684',
685
+ 0xFB74: '\u0684',
686
+ 0xFB75: '\u0684',
687
+ 0xFB76: '\u0683',
688
+ 0xFB77: '\u0683',
689
+ 0xFB78: '\u0683',
690
+ 0xFB79: '\u0683',
691
+ 0xFB7A: '\u0686',
692
+ 0xFB7B: '\u0686',
693
+ 0xFB7C: '\u0686',
694
+ 0xFB7D: '\u0686',
695
+ 0xFB7E: '\u0687',
696
+ 0xFB7F: '\u0687',
697
+ 0xFB80: '\u0687',
698
+ 0xFB81: '\u0687',
699
+ 0xFB82: '\u068d',
700
+ 0xFB83: '\u068d',
701
+ 0xFB84: '\u068c',
702
+ 0xFB85: '\u068c',
703
+ 0xFB86: '\u068e',
704
+ 0xFB87: '\u068e',
705
+ 0xFB88: '\u0688',
706
+ 0xFB89: '\u0688',
707
+ 0xFB8A: '\u0698',
708
+ 0xFB8B: '\u0698',
709
+ 0xFB8C: '\u0691',
710
+ 0xFB8D: '\u0691',
711
+ 0xFB8E: '\u06a9',
712
+ 0xFB8F: '\u06a9',
713
+ 0xFB90: '\u06a9',
714
+ 0xFB91: '\u06a9',
715
+ 0xFB92: '\u06af',
716
+ 0xFB93: '\u06af',
717
+ 0xFB94: '\u06af',
718
+ 0xFB95: '\u06af',
719
+ 0xFB96: '\u06b3',
720
+ 0xFB97: '\u06b3',
721
+ 0xFB98: '\u06b3',
722
+ 0xFB99: '\u06b3',
723
+ 0xFB9A: '\u06b1',
724
+ 0xFB9B: '\u06b1',
725
+ 0xFB9C: '\u06b1',
726
+ 0xFB9D: '\u06b1',
727
+ 0xFB9E: '\u06ba',
728
+ 0xFB9F: '\u06ba',
729
+ 0xFBA0: '\u06bb',
730
+ 0xFBA1: '\u06bb',
731
+ 0xFBA2: '\u06bb',
732
+ 0xFBA3: '\u06bb',
733
+ 0xFBA4: '\u06c0',
734
+ 0xFBA5: '\u06c0',
735
+ 0xFBA6: '\u06c1',
736
+ 0xFBA7: '\u06c1',
737
+ 0xFBA8: '\u06c1',
738
+ 0xFBA9: '\u06c1',
739
+ 0xFBAA: '\u06be',
740
+ 0xFBAB: '\u06be',
741
+ 0xFBAC: '\u06be',
742
+ 0xFBAD: '\u06be',
743
+ 0xFBAE: '\u06d2',
744
+ 0xFBAF: '\u06d2',
745
+ 0xFBB0: '\u06d3',
746
+ 0xFBB1: '\u06d3',
747
+ 0xFBD3: '\u06ad',
748
+ 0xFBD4: '\u06ad',
749
+ 0xFBD5: '\u06ad',
750
+ 0xFBD6: '\u06ad',
751
+ 0xFBD7: '\u06c7',
752
+ 0xFBD8: '\u06c7',
753
+ 0xFBD9: '\u06c6',
754
+ 0xFBDA: '\u06c6',
755
+ 0xFBDB: '\u06c8',
756
+ 0xFBDC: '\u06c8',
757
+ 0xFBDD: '\u06c7\u0674',
758
+ 0xFBDE: '\u06cb',
759
+ 0xFBDF: '\u06cb',
760
+ 0xFBE0: '\u06c5',
761
+ 0xFBE1: '\u06c5',
762
+ 0xFBE2: '\u06c9',
763
+ 0xFBE3: '\u06c9',
764
+ 0xFBE4: '\u06d0',
765
+ 0xFBE5: '\u06d0',
766
+ 0xFBE6: '\u06d0',
767
+ 0xFBE7: '\u06d0',
768
+ 0xFBE8: '\u0649',
769
+ 0xFBE9: '\u0649',
770
+ 0xFBEA: '\u0626\u0627',
771
+ 0xFBEB: '\u0626\u0627',
772
+ 0xFBEC: '\u0626\u06d5',
773
+ 0xFBED: '\u0626\u06d5',
774
+ 0xFBEE: '\u0626\u0648',
775
+ 0xFBEF: '\u0626\u0648',
776
+ 0xFBF0: '\u0626\u06c7',
777
+ 0xFBF1: '\u0626\u06c7',
778
+ 0xFBF2: '\u0626\u06c6',
779
+ 0xFBF3: '\u0626\u06c6',
780
+ 0xFBF4: '\u0626\u06c8',
781
+ 0xFBF5: '\u0626\u06c8',
782
+ 0xFBF6: '\u0626\u06d0',
783
+ 0xFBF7: '\u0626\u06d0',
784
+ 0xFBF8: '\u0626\u06d0',
785
+ 0xFBF9: '\u0626\u0649',
786
+ 0xFBFA: '\u0626\u0649',
787
+ 0xFBFB: '\u0626\u0649',
788
+ 0xFBFC: '\u06cc',
789
+ 0xFBFD: '\u06cc',
790
+ 0xFBFE: '\u06cc',
791
+ 0xFBFF: '\u06cc',
792
+ 0xFC00: '\u0626\u062c',
793
+ 0xFC01: '\u0626\u062d',
794
+ 0xFC02: '\u0626\u0645',
795
+ 0xFC03: '\u0626\u0649',
796
+ 0xFC04: '\u0626\u064a',
797
+ 0xFC05: '\u0628\u062c',
798
+ 0xFC06: '\u0628\u062d',
799
+ 0xFC07: '\u0628\u062e',
800
+ 0xFC08: '\u0628\u0645',
801
+ 0xFC09: '\u0628\u0649',
802
+ 0xFC0A: '\u0628\u064a',
803
+ 0xFC0B: '\u062a\u062c',
804
+ 0xFC0C: '\u062a\u062d',
805
+ 0xFC0D: '\u062a\u062e',
806
+ 0xFC0E: '\u062a\u0645',
807
+ 0xFC0F: '\u062a\u0649',
808
+ 0xFC10: '\u062a\u064a',
809
+ 0xFC11: '\u062b\u062c',
810
+ 0xFC12: '\u062b\u0645',
811
+ 0xFC13: '\u062b\u0649',
812
+ 0xFC14: '\u062b\u064a',
813
+ 0xFC15: '\u062c\u062d',
814
+ 0xFC16: '\u062c\u0645',
815
+ 0xFC17: '\u062d\u062c',
816
+ 0xFC18: '\u062d\u0645',
817
+ 0xFC19: '\u062e\u062c',
818
+ 0xFC1A: '\u062e\u062d',
819
+ 0xFC1B: '\u062e\u0645',
820
+ 0xFC1C: '\u0633\u062c',
821
+ 0xFC1D: '\u0633\u062d',
822
+ 0xFC1E: '\u0633\u062e',
823
+ 0xFC1F: '\u0633\u0645',
824
+ 0xFC20: '\u0635\u062d',
825
+ 0xFC21: '\u0635\u0645',
826
+ 0xFC22: '\u0636\u062c',
827
+ 0xFC23: '\u0636\u062d',
828
+ 0xFC24: '\u0636\u062e',
829
+ 0xFC25: '\u0636\u0645',
830
+ 0xFC26: '\u0637\u062d',
831
+ 0xFC27: '\u0637\u0645',
832
+ 0xFC28: '\u0638\u0645',
833
+ 0xFC29: '\u0639\u062c',
834
+ 0xFC2A: '\u0639\u0645',
835
+ 0xFC2B: '\u063a\u062c',
836
+ 0xFC2C: '\u063a\u0645',
837
+ 0xFC2D: '\u0641\u062c',
838
+ 0xFC2E: '\u0641\u062d',
839
+ 0xFC2F: '\u0641\u062e',
840
+ 0xFC30: '\u0641\u0645',
841
+ 0xFC31: '\u0641\u0649',
842
+ 0xFC32: '\u0641\u064a',
843
+ 0xFC33: '\u0642\u062d',
844
+ 0xFC34: '\u0642\u0645',
845
+ 0xFC35: '\u0642\u0649',
846
+ 0xFC36: '\u0642\u064a',
847
+ 0xFC37: '\u0643\u0627',
848
+ 0xFC38: '\u0643\u062c',
849
+ 0xFC39: '\u0643\u062d',
850
+ 0xFC3A: '\u0643\u062e',
851
+ 0xFC3B: '\u0643\u0644',
852
+ 0xFC3C: '\u0643\u0645',
853
+ 0xFC3D: '\u0643\u0649',
854
+ 0xFC3E: '\u0643\u064a',
855
+ 0xFC3F: '\u0644\u062c',
856
+ 0xFC40: '\u0644\u062d',
857
+ 0xFC41: '\u0644\u062e',
858
+ 0xFC42: '\u0644\u0645',
859
+ 0xFC43: '\u0644\u0649',
860
+ 0xFC44: '\u0644\u064a',
861
+ 0xFC45: '\u0645\u062c',
862
+ 0xFC46: '\u0645\u062d',
863
+ 0xFC47: '\u0645\u062e',
864
+ 0xFC48: '\u0645\u0645',
865
+ 0xFC49: '\u0645\u0649',
866
+ 0xFC4A: '\u0645\u064a',
867
+ 0xFC4B: '\u0646\u062c',
868
+ 0xFC4C: '\u0646\u062d',
869
+ 0xFC4D: '\u0646\u062e',
870
+ 0xFC4E: '\u0646\u0645',
871
+ 0xFC4F: '\u0646\u0649',
872
+ 0xFC50: '\u0646\u064a',
873
+ 0xFC51: '\u0647\u062c',
874
+ 0xFC52: '\u0647\u0645',
875
+ 0xFC53: '\u0647\u0649',
876
+ 0xFC54: '\u0647\u064a',
877
+ 0xFC55: '\u064a\u062c',
878
+ 0xFC56: '\u064a\u062d',
879
+ 0xFC57: '\u064a\u062e',
880
+ 0xFC58: '\u064a\u0645',
881
+ 0xFC59: '\u064a\u0649',
882
+ 0xFC5A: '\u064a\u064a',
883
+ 0xFC5B: '\u0630\u0670',
884
+ 0xFC5C: '\u0631\u0670',
885
+ 0xFC5D: '\u0649\u0670',
886
+ 0xFC5E: '\u064c\u0651',
887
+ 0xFC5F: '\u064d\u0651',
888
+ 0xFC60: '\u064e\u0651',
889
+ 0xFC61: '\u064f\u0651',
890
+ 0xFC62: '\u0650\u0651',
891
+ 0xFC63: '\u0651\u0670',
892
+ 0xFC64: '\u0626\u0631',
893
+ 0xFC65: '\u0626\u0632',
894
+ 0xFC66: '\u0626\u0645',
895
+ 0xFC67: '\u0626\u0646',
896
+ 0xFC68: '\u0626\u0649',
897
+ 0xFC69: '\u0626\u064a',
898
+ 0xFC6A: '\u0628\u0631',
899
+ 0xFC6B: '\u0628\u0632',
900
+ 0xFC6C: '\u0628\u0645',
901
+ 0xFC6D: '\u0628\u0646',
902
+ 0xFC6E: '\u0628\u0649',
903
+ 0xFC6F: '\u0628\u064a',
904
+ 0xFC70: '\u062a\u0631',
905
+ 0xFC71: '\u062a\u0632',
906
+ 0xFC72: '\u062a\u0645',
907
+ 0xFC73: '\u062a\u0646',
908
+ 0xFC74: '\u062a\u0649',
909
+ 0xFC75: '\u062a\u064a',
910
+ 0xFC76: '\u062b\u0631',
911
+ 0xFC77: '\u062b\u0632',
912
+ 0xFC78: '\u062b\u0645',
913
+ 0xFC79: '\u062b\u0646',
914
+ 0xFC7A: '\u062b\u0649',
915
+ 0xFC7B: '\u062b\u064a',
916
+ 0xFC7C: '\u0641\u0649',
917
+ 0xFC7D: '\u0641\u064a',
918
+ 0xFC7E: '\u0642\u0649',
919
+ 0xFC7F: '\u0642\u064a',
920
+ 0xFC80: '\u0643\u0627',
921
+ 0xFC81: '\u0643\u0644',
922
+ 0xFC82: '\u0643\u0645',
923
+ 0xFC83: '\u0643\u0649',
924
+ 0xFC84: '\u0643\u064a',
925
+ 0xFC85: '\u0644\u0645',
926
+ 0xFC86: '\u0644\u0649',
927
+ 0xFC87: '\u0644\u064a',
928
+ 0xFC88: '\u0645\u0627',
929
+ 0xFC89: '\u0645\u0645',
930
+ 0xFC8A: '\u0646\u0631',
931
+ 0xFC8B: '\u0646\u0632',
932
+ 0xFC8C: '\u0646\u0645',
933
+ 0xFC8D: '\u0646\u0646',
934
+ 0xFC8E: '\u0646\u0649',
935
+ 0xFC8F: '\u0646\u064a',
936
+ 0xFC90: '\u0649\u0670',
937
+ 0xFC91: '\u064a\u0631',
938
+ 0xFC92: '\u064a\u0632',
939
+ 0xFC93: '\u064a\u0645',
940
+ 0xFC94: '\u064a\u0646',
941
+ 0xFC95: '\u064a\u0649',
942
+ 0xFC96: '\u064a\u064a',
943
+ 0xFC97: '\u0626\u062c',
944
+ 0xFC98: '\u0626\u062d',
945
+ 0xFC99: '\u0626\u062e',
946
+ 0xFC9A: '\u0626\u0645',
947
+ 0xFC9B: '\u0626\u0647',
948
+ 0xFC9C: '\u0628\u062c',
949
+ 0xFC9D: '\u0628\u062d',
950
+ 0xFC9E: '\u0628\u062e',
951
+ 0xFC9F: '\u0628\u0645',
952
+ 0xFCA0: '\u0628\u0647',
953
+ 0xFCA1: '\u062a\u062c',
954
+ 0xFCA2: '\u062a\u062d',
955
+ 0xFCA3: '\u062a\u062e',
956
+ 0xFCA4: '\u062a\u0645',
957
+ 0xFCA5: '\u062a\u0647',
958
+ 0xFCA6: '\u062b\u0645',
959
+ 0xFCA7: '\u062c\u062d',
960
+ 0xFCA8: '\u062c\u0645',
961
+ 0xFCA9: '\u062d\u062c',
962
+ 0xFCAA: '\u062d\u0645',
963
+ 0xFCAB: '\u062e\u062c',
964
+ 0xFCAC: '\u062e\u0645',
965
+ 0xFCAD: '\u0633\u062c',
966
+ 0xFCAE: '\u0633\u062d',
967
+ 0xFCAF: '\u0633\u062e',
968
+ 0xFCB0: '\u0633\u0645',
969
+ 0xFCB1: '\u0635\u062d',
970
+ 0xFCB2: '\u0635\u062e',
971
+ 0xFCB3: '\u0635\u0645',
972
+ 0xFCB4: '\u0636\u062c',
973
+ 0xFCB5: '\u0636\u062d',
974
+ 0xFCB6: '\u0636\u062e',
975
+ 0xFCB7: '\u0636\u0645',
976
+ 0xFCB8: '\u0637\u062d',
977
+ 0xFCB9: '\u0638\u0645',
978
+ 0xFCBA: '\u0639\u062c',
979
+ 0xFCBB: '\u0639\u0645',
980
+ 0xFCBC: '\u063a\u062c',
981
+ 0xFCBD: '\u063a\u0645',
982
+ 0xFCBE: '\u0641\u062c',
983
+ 0xFCBF: '\u0641\u062d',
984
+ 0xFCC0: '\u0641\u062e',
985
+ 0xFCC1: '\u0641\u0645',
986
+ 0xFCC2: '\u0642\u062d',
987
+ 0xFCC3: '\u0642\u0645',
988
+ 0xFCC4: '\u0643\u062c',
989
+ 0xFCC5: '\u0643\u062d',
990
+ 0xFCC6: '\u0643\u062e',
991
+ 0xFCC7: '\u0643\u0644',
992
+ 0xFCC8: '\u0643\u0645',
993
+ 0xFCC9: '\u0644\u062c',
994
+ 0xFCCA: '\u0644\u062d',
995
+ 0xFCCB: '\u0644\u062e',
996
+ 0xFCCC: '\u0644\u0645',
997
+ 0xFCCD: '\u0644\u0647',
998
+ 0xFCCE: '\u0645\u062c',
999
+ 0xFCCF: '\u0645\u062d',
1000
+ 0xFCD0: '\u0645\u062e',
1001
+ 0xFCD1: '\u0645\u0645',
1002
+ 0xFCD2: '\u0646\u062c',
1003
+ 0xFCD3: '\u0646\u062d',
1004
+ 0xFCD4: '\u0646\u062e',
1005
+ 0xFCD5: '\u0646\u0645',
1006
+ 0xFCD6: '\u0646\u0647',
1007
+ 0xFCD7: '\u0647\u062c',
1008
+ 0xFCD8: '\u0647\u0645',
1009
+ 0xFCD9: '\u0647\u0670',
1010
+ 0xFCDA: '\u064a\u062c',
1011
+ 0xFCDB: '\u064a\u062d',
1012
+ 0xFCDC: '\u064a\u062e',
1013
+ 0xFCDD: '\u064a\u0645',
1014
+ 0xFCDE: '\u064a\u0647',
1015
+ 0xFCDF: '\u0626\u0645',
1016
+ 0xFCE0: '\u0626\u0647',
1017
+ 0xFCE1: '\u0628\u0645',
1018
+ 0xFCE2: '\u0628\u0647',
1019
+ 0xFCE3: '\u062a\u0645',
1020
+ 0xFCE4: '\u062a\u0647',
1021
+ 0xFCE5: '\u062b\u0645',
1022
+ 0xFCE6: '\u062b\u0647',
1023
+ 0xFCE7: '\u0633\u0645',
1024
+ 0xFCE8: '\u0633\u0647',
1025
+ 0xFCE9: '\u0634\u0645',
1026
+ 0xFCEA: '\u0634\u0647',
1027
+ 0xFCEB: '\u0643\u0644',
1028
+ 0xFCEC: '\u0643\u0645',
1029
+ 0xFCED: '\u0644\u0645',
1030
+ 0xFCEE: '\u0646\u0645',
1031
+ 0xFCEF: '\u0646\u0647',
1032
+ 0xFCF0: '\u064a\u0645',
1033
+ 0xFCF1: '\u064a\u0647',
1034
+ 0xFCF2: '\u0640\u064e\u0651',
1035
+ 0xFCF3: '\u0640\u064f\u0651',
1036
+ 0xFCF4: '\u0640\u0650\u0651',
1037
+ 0xFCF5: '\u0637\u0649',
1038
+ 0xFCF6: '\u0637\u064a',
1039
+ 0xFCF7: '\u0639\u0649',
1040
+ 0xFCF8: '\u0639\u064a',
1041
+ 0xFCF9: '\u063a\u0649',
1042
+ 0xFCFA: '\u063a\u064a',
1043
+ 0xFCFB: '\u0633\u0649',
1044
+ 0xFCFC: '\u0633\u064a',
1045
+ 0xFCFD: '\u0634\u0649',
1046
+ 0xFCFE: '\u0634\u064a',
1047
+ 0xFCFF: '\u062d\u0649',
1048
+ 0xFD00: '\u062d\u064a',
1049
+ 0xFD01: '\u062c\u0649',
1050
+ 0xFD02: '\u062c\u064a',
1051
+ 0xFD03: '\u062e\u0649',
1052
+ 0xFD04: '\u062e\u064a',
1053
+ 0xFD05: '\u0635\u0649',
1054
+ 0xFD06: '\u0635\u064a',
1055
+ 0xFD07: '\u0636\u0649',
1056
+ 0xFD08: '\u0636\u064a',
1057
+ 0xFD09: '\u0634\u062c',
1058
+ 0xFD0A: '\u0634\u062d',
1059
+ 0xFD0B: '\u0634\u062e',
1060
+ 0xFD0C: '\u0634\u0645',
1061
+ 0xFD0D: '\u0634\u0631',
1062
+ 0xFD0E: '\u0633\u0631',
1063
+ 0xFD0F: '\u0635\u0631',
1064
+ 0xFD10: '\u0636\u0631',
1065
+ 0xFD11: '\u0637\u0649',
1066
+ 0xFD12: '\u0637\u064a',
1067
+ 0xFD13: '\u0639\u0649',
1068
+ 0xFD14: '\u0639\u064a',
1069
+ 0xFD15: '\u063a\u0649',
1070
+ 0xFD16: '\u063a\u064a',
1071
+ 0xFD17: '\u0633\u0649',
1072
+ 0xFD18: '\u0633\u064a',
1073
+ 0xFD19: '\u0634\u0649',
1074
+ 0xFD1A: '\u0634\u064a',
1075
+ 0xFD1B: '\u062d\u0649',
1076
+ 0xFD1C: '\u062d\u064a',
1077
+ 0xFD1D: '\u062c\u0649',
1078
+ 0xFD1E: '\u062c\u064a',
1079
+ 0xFD1F: '\u062e\u0649',
1080
+ 0xFD20: '\u062e\u064a',
1081
+ 0xFD21: '\u0635\u0649',
1082
+ 0xFD22: '\u0635\u064a',
1083
+ 0xFD23: '\u0636\u0649',
1084
+ 0xFD24: '\u0636\u064a',
1085
+ 0xFD25: '\u0634\u062c',
1086
+ 0xFD26: '\u0634\u062d',
1087
+ 0xFD27: '\u0634\u062e',
1088
+ 0xFD28: '\u0634\u0645',
1089
+ 0xFD29: '\u0634\u0631',
1090
+ 0xFD2A: '\u0633\u0631',
1091
+ 0xFD2B: '\u0635\u0631',
1092
+ 0xFD2C: '\u0636\u0631',
1093
+ 0xFD2D: '\u0634\u062c',
1094
+ 0xFD2E: '\u0634\u062d',
1095
+ 0xFD2F: '\u0634\u062e',
1096
+ 0xFD30: '\u0634\u0645',
1097
+ 0xFD31: '\u0633\u0647',
1098
+ 0xFD32: '\u0634\u0647',
1099
+ 0xFD33: '\u0637\u0645',
1100
+ 0xFD34: '\u0633\u062c',
1101
+ 0xFD35: '\u0633\u062d',
1102
+ 0xFD36: '\u0633\u062e',
1103
+ 0xFD37: '\u0634\u062c',
1104
+ 0xFD38: '\u0634\u062d',
1105
+ 0xFD39: '\u0634\u062e',
1106
+ 0xFD3A: '\u0637\u0645',
1107
+ 0xFD3B: '\u0638\u0645',
1108
+ 0xFD3C: '\u0627\u064b',
1109
+ 0xFD3D: '\u0627\u064b',
1110
+ 0xFD50: '\u062a\u062c\u0645',
1111
+ 0xFD51: '\u062a\u062d\u062c',
1112
+ 0xFD52: '\u062a\u062d\u062c',
1113
+ 0xFD53: '\u062a\u062d\u0645',
1114
+ 0xFD54: '\u062a\u062e\u0645',
1115
+ 0xFD55: '\u062a\u0645\u062c',
1116
+ 0xFD56: '\u062a\u0645\u062d',
1117
+ 0xFD57: '\u062a\u0645\u062e',
1118
+ 0xFD58: '\u062c\u0645\u062d',
1119
+ 0xFD59: '\u062c\u0645\u062d',
1120
+ 0xFD5A: '\u062d\u0645\u064a',
1121
+ 0xFD5B: '\u062d\u0645\u0649',
1122
+ 0xFD5C: '\u0633\u062d\u062c',
1123
+ 0xFD5D: '\u0633\u062c\u062d',
1124
+ 0xFD5E: '\u0633\u062c\u0649',
1125
+ 0xFD5F: '\u0633\u0645\u062d',
1126
+ 0xFD60: '\u0633\u0645\u062d',
1127
+ 0xFD61: '\u0633\u0645\u062c',
1128
+ 0xFD62: '\u0633\u0645\u0645',
1129
+ 0xFD63: '\u0633\u0645\u0645',
1130
+ 0xFD64: '\u0635\u062d\u062d',
1131
+ 0xFD65: '\u0635\u062d\u062d',
1132
+ 0xFD66: '\u0635\u0645\u0645',
1133
+ 0xFD67: '\u0634\u062d\u0645',
1134
+ 0xFD68: '\u0634\u062d\u0645',
1135
+ 0xFD69: '\u0634\u062c\u064a',
1136
+ 0xFD6A: '\u0634\u0645\u062e',
1137
+ 0xFD6B: '\u0634\u0645\u062e',
1138
+ 0xFD6C: '\u0634\u0645\u0645',
1139
+ 0xFD6D: '\u0634\u0645\u0645',
1140
+ 0xFD6E: '\u0636\u062d\u0649',
1141
+ 0xFD6F: '\u0636\u062e\u0645',
1142
+ 0xFD70: '\u0636\u062e\u0645',
1143
+ 0xFD71: '\u0637\u0645\u062d',
1144
+ 0xFD72: '\u0637\u0645\u062d',
1145
+ 0xFD73: '\u0637\u0645\u0645',
1146
+ 0xFD74: '\u0637\u0645\u064a',
1147
+ 0xFD75: '\u0639\u062c\u0645',
1148
+ 0xFD76: '\u0639\u0645\u0645',
1149
+ 0xFD77: '\u0639\u0645\u0645',
1150
+ 0xFD78: '\u0639\u0645\u0649',
1151
+ 0xFD79: '\u063a\u0645\u0645',
1152
+ 0xFD7A: '\u063a\u0645\u064a',
1153
+ 0xFD7B: '\u063a\u0645\u0649',
1154
+ 0xFD7C: '\u0641\u062e\u0645',
1155
+ 0xFD7D: '\u0641\u062e\u0645',
1156
+ 0xFD7E: '\u0642\u0645\u062d',
1157
+ 0xFD7F: '\u0642\u0645\u0645',
1158
+ 0xFD80: '\u0644\u062d\u0645',
1159
+ 0xFD81: '\u0644\u062d\u064a',
1160
+ 0xFD82: '\u0644\u062d\u0649',
1161
+ 0xFD83: '\u0644\u062c\u062c',
1162
+ 0xFD84: '\u0644\u062c\u062c',
1163
+ 0xFD85: '\u0644\u062e\u0645',
1164
+ 0xFD86: '\u0644\u062e\u0645',
1165
+ 0xFD87: '\u0644\u0645\u062d',
1166
+ 0xFD88: '\u0644\u0645\u062d',
1167
+ 0xFD89: '\u0645\u062d\u062c',
1168
+ 0xFD8A: '\u0645\u062d\u0645',
1169
+ 0xFD8B: '\u0645\u062d\u064a',
1170
+ 0xFD8C: '\u0645\u062c\u062d',
1171
+ 0xFD8D: '\u0645\u062c\u0645',
1172
+ 0xFD8E: '\u0645\u062e\u062c',
1173
+ 0xFD8F: '\u0645\u062e\u0645',
1174
+ 0xFD92: '\u0645\u062c\u062e',
1175
+ 0xFD93: '\u0647\u0645\u062c',
1176
+ 0xFD94: '\u0647\u0645\u0645',
1177
+ 0xFD95: '\u0646\u062d\u0645',
1178
+ 0xFD96: '\u0646\u062d\u0649',
1179
+ 0xFD97: '\u0646\u062c\u0645',
1180
+ 0xFD98: '\u0646\u062c\u0645',
1181
+ 0xFD99: '\u0646\u062c\u0649',
1182
+ 0xFD9A: '\u0646\u0645\u064a',
1183
+ 0xFD9B: '\u0646\u0645\u0649',
1184
+ 0xFD9C: '\u064a\u0645\u0645',
1185
+ 0xFD9D: '\u064a\u0645\u0645',
1186
+ 0xFD9E: '\u0628\u062e\u064a',
1187
+ 0xFD9F: '\u062a\u062c\u064a',
1188
+ 0xFDA0: '\u062a\u062c\u0649',
1189
+ 0xFDA1: '\u062a\u062e\u064a',
1190
+ 0xFDA2: '\u062a\u062e\u0649',
1191
+ 0xFDA3: '\u062a\u0645\u064a',
1192
+ 0xFDA4: '\u062a\u0645\u0649',
1193
+ 0xFDA5: '\u062c\u0645\u064a',
1194
+ 0xFDA6: '\u062c\u062d\u0649',
1195
+ 0xFDA7: '\u062c\u0645\u0649',
1196
+ 0xFDA8: '\u0633\u062e\u0649',
1197
+ 0xFDA9: '\u0635\u062d\u064a',
1198
+ 0xFDAA: '\u0634\u062d\u064a',
1199
+ 0xFDAB: '\u0636\u062d\u064a',
1200
+ 0xFDAC: '\u0644\u062c\u064a',
1201
+ 0xFDAD: '\u0644\u0645\u064a',
1202
+ 0xFDAE: '\u064a\u062d\u064a',
1203
+ 0xFDAF: '\u064a\u062c\u064a',
1204
+ 0xFDB0: '\u064a\u0645\u064a',
1205
+ 0xFDB1: '\u0645\u0645\u064a',
1206
+ 0xFDB2: '\u0642\u0645\u064a',
1207
+ 0xFDB3: '\u0646\u062d\u064a',
1208
+ 0xFDB4: '\u0642\u0645\u062d',
1209
+ 0xFDB5: '\u0644\u062d\u0645',
1210
+ 0xFDB6: '\u0639\u0645\u064a',
1211
+ 0xFDB7: '\u0643\u0645\u064a',
1212
+ 0xFDB8: '\u0646\u062c\u062d',
1213
+ 0xFDB9: '\u0645\u062e\u064a',
1214
+ 0xFDBA: '\u0644\u062c\u0645',
1215
+ 0xFDBB: '\u0643\u0645\u0645',
1216
+ 0xFDBC: '\u0644\u062c\u0645',
1217
+ 0xFDBD: '\u0646\u062c\u062d',
1218
+ 0xFDBE: '\u062c\u062d\u064a',
1219
+ 0xFDBF: '\u062d\u062c\u064a',
1220
+ 0xFDC0: '\u0645\u062c\u064a',
1221
+ 0xFDC1: '\u0641\u0645\u064a',
1222
+ 0xFDC2: '\u0628\u062d\u064a',
1223
+ 0xFDC3: '\u0643\u0645\u0645',
1224
+ 0xFDC4: '\u0639\u062c\u0645',
1225
+ 0xFDC5: '\u0635\u0645\u0645',
1226
+ 0xFDC6: '\u0633\u062e\u064a',
1227
+ 0xFDC7: '\u0646\u062c\u064a',
1228
+ 0xFDF0: '\u0635\u0644\u06d2',
1229
+ 0xFDF1: '\u0642\u0644\u06d2',
1230
+ 0xFDF2: '\u0627\u0644\u0644\u0647',
1231
+ 0xFDF3: '\u0627\u0643\u0628\u0631',
1232
+ 0xFDF4: '\u0645\u062d\u0645\u062f',
1233
+ 0xFDF5: '\u0635\u0644\u0639\u0645',
1234
+ 0xFDF6: '\u0631\u0633\u0648\u0644',
1235
+ 0xFDF7: '\u0639\u0644\u064a\u0647',
1236
+ 0xFDF8: '\u0648\u0633\u0644\u0645',
1237
+ 0xFDF9: '\u0635\u0644\u0649',
1238
+ 0xFDFA: '\u0635\u0644\u0649\u0627\u0644\u0644\u0647\u0639\u0644\u064a\u0647\u0648\u0633\u0644\u0645',
1239
+ 0xFDFB: '\u062c\u0644\u062c\u0644\u0627\u0644\u0647',
1240
+ 0xFDFC: '\u0631\u06cc\u0627\u0644',
1241
+ 0xFE70: '\u064b',
1242
+ 0xFE71: '\u0640\u064b',
1243
+ 0xFE72: '\u064c',
1244
+ 0xFE74: '\u064d',
1245
+ 0xFE76: '\u064e',
1246
+ 0xFE77: '\u0640\u064e',
1247
+ 0xFE78: '\u064f',
1248
+ 0xFE79: '\u0640\u064f',
1249
+ 0xFE7A: '\u0650',
1250
+ 0xFE7B: '\u0640\u0650',
1251
+ 0xFE7C: '\u0651',
1252
+ 0xFE7D: '\u0640\u0651',
1253
+ 0xFE7E: '\u0652',
1254
+ 0xFE7F: '\u0640\u0652',
1255
+ 0xFE80: '\u0621',
1256
+ 0xFE81: '\u0622',
1257
+ 0xFE82: '\u0622',
1258
+ 0xFE83: '\u0623',
1259
+ 0xFE84: '\u0623',
1260
+ 0xFE85: '\u0624',
1261
+ 0xFE86: '\u0624',
1262
+ 0xFE87: '\u0625',
1263
+ 0xFE88: '\u0625',
1264
+ 0xFE89: '\u0626',
1265
+ 0xFE8A: '\u0626',
1266
+ 0xFE8B: '\u0626',
1267
+ 0xFE8C: '\u0626',
1268
+ 0xFE8D: '\u0627',
1269
+ 0xFE8E: '\u0627',
1270
+ 0xFE8F: '\u0628',
1271
+ 0xFE90: '\u0628',
1272
+ 0xFE91: '\u0628',
1273
+ 0xFE92: '\u0628',
1274
+ 0xFE93: '\u0629',
1275
+ 0xFE94: '\u0629',
1276
+ 0xFE95: '\u062a',
1277
+ 0xFE96: '\u062a',
1278
+ 0xFE97: '\u062a',
1279
+ 0xFE98: '\u062a',
1280
+ 0xFE99: '\u062b',
1281
+ 0xFE9A: '\u062b',
1282
+ 0xFE9B: '\u062b',
1283
+ 0xFE9C: '\u062b',
1284
+ 0xFE9D: '\u062c',
1285
+ 0xFE9E: '\u062c',
1286
+ 0xFE9F: '\u062c',
1287
+ 0xFEA0: '\u062c',
1288
+ 0xFEA1: '\u062d',
1289
+ 0xFEA2: '\u062d',
1290
+ 0xFEA3: '\u062d',
1291
+ 0xFEA4: '\u062d',
1292
+ 0xFEA5: '\u062e',
1293
+ 0xFEA6: '\u062e',
1294
+ 0xFEA7: '\u062e',
1295
+ 0xFEA8: '\u062e',
1296
+ 0xFEA9: '\u062f',
1297
+ 0xFEAA: '\u062f',
1298
+ 0xFEAB: '\u0630',
1299
+ 0xFEAC: '\u0630',
1300
+ 0xFEAD: '\u0631',
1301
+ 0xFEAE: '\u0631',
1302
+ 0xFEAF: '\u0632',
1303
+ 0xFEB0: '\u0632',
1304
+ 0xFEB1: '\u0633',
1305
+ 0xFEB2: '\u0633',
1306
+ 0xFEB3: '\u0633',
1307
+ 0xFEB4: '\u0633',
1308
+ 0xFEB5: '\u0634',
1309
+ 0xFEB6: '\u0634',
1310
+ 0xFEB7: '\u0634',
1311
+ 0xFEB8: '\u0634',
1312
+ 0xFEB9: '\u0635',
1313
+ 0xFEBA: '\u0635',
1314
+ 0xFEBB: '\u0635',
1315
+ 0xFEBC: '\u0635',
1316
+ 0xFEBD: '\u0636',
1317
+ 0xFEBE: '\u0636',
1318
+ 0xFEBF: '\u0636',
1319
+ 0xFEC0: '\u0636',
1320
+ 0xFEC1: '\u0637',
1321
+ 0xFEC2: '\u0637',
1322
+ 0xFEC3: '\u0637',
1323
+ 0xFEC4: '\u0637',
1324
+ 0xFEC5: '\u0638',
1325
+ 0xFEC6: '\u0638',
1326
+ 0xFEC7: '\u0638',
1327
+ 0xFEC8: '\u0638',
1328
+ 0xFEC9: '\u0639',
1329
+ 0xFECA: '\u0639',
1330
+ 0xFECB: '\u0639',
1331
+ 0xFECC: '\u0639',
1332
+ 0xFECD: '\u063a',
1333
+ 0xFECE: '\u063a',
1334
+ 0xFECF: '\u063a',
1335
+ 0xFED0: '\u063a',
1336
+ 0xFED1: '\u0641',
1337
+ 0xFED2: '\u0641',
1338
+ 0xFED3: '\u0641',
1339
+ 0xFED4: '\u0641',
1340
+ 0xFED5: '\u0642',
1341
+ 0xFED6: '\u0642',
1342
+ 0xFED7: '\u0642',
1343
+ 0xFED8: '\u0642',
1344
+ 0xFED9: '\u0643',
1345
+ 0xFEDA: '\u0643',
1346
+ 0xFEDB: '\u0643',
1347
+ 0xFEDC: '\u0643',
1348
+ 0xFEDD: '\u0644',
1349
+ 0xFEDE: '\u0644',
1350
+ 0xFEDF: '\u0644',
1351
+ 0xFEE0: '\u0644',
1352
+ 0xFEE1: '\u0645',
1353
+ 0xFEE2: '\u0645',
1354
+ 0xFEE3: '\u0645',
1355
+ 0xFEE4: '\u0645',
1356
+ 0xFEE5: '\u0646',
1357
+ 0xFEE6: '\u0646',
1358
+ 0xFEE7: '\u0646',
1359
+ 0xFEE8: '\u0646',
1360
+ 0xFEE9: '\u0647',
1361
+ 0xFEEA: '\u0647',
1362
+ 0xFEEB: '\u0647',
1363
+ 0xFEEC: '\u0647',
1364
+ 0xFEED: '\u0648',
1365
+ 0xFEEE: '\u0648',
1366
+ 0xFEEF: '\u0649',
1367
+ 0xFEF0: '\u0649',
1368
+ 0xFEF1: '\u064a',
1369
+ 0xFEF2: '\u064a',
1370
+ 0xFEF3: '\u064a',
1371
+ 0xFEF4: '\u064a',
1372
+ 0xFEF5: '\u0644\u0622',
1373
+ 0xFEF6: '\u0644\u0622',
1374
+ 0xFEF7: '\u0644\u0623',
1375
+ 0xFEF8: '\u0644\u0623',
1376
+ 0xFEF9: '\u0644\u0625',
1377
+ 0xFEFA: '\u0644\u0625',
1378
+ 0xFEFB: '\u0644\u0627',
1379
+ 0xFEFC: '\u0644\u0627'
1380
+ };