@vaadin-component-factory/vcf-pdf-viewer 0.9.0 → 0.9.4

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.
Files changed (174) hide show
  1. package/README.md +1 -1
  2. package/package.json +33 -18
  3. package/{src/display → pdfjs/dist}/display_utils.js +344 -139
  4. package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
  5. package/pdfjs/dist/get.js +1857 -0
  6. package/pdfjs/dist/index.js +767 -0
  7. package/pdfjs/dist/l10n_utils.js +140 -0
  8. package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
  9. package/{src/display → pdfjs/dist}/network.js +149 -87
  10. package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
  11. package/{src/display → pdfjs/dist}/node_stream.js +133 -98
  12. package/pdfjs/dist/pdf.js +12778 -0
  13. package/pdfjs/dist/pdf_link_service.js +638 -0
  14. package/pdfjs/dist/pdf_rendering_queue.js +199 -0
  15. package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
  16. package/pdfjs/dist/pdf_viewer.js +3598 -0
  17. package/pdfjs/dist/typeof.js +100 -0
  18. package/pdfjs/dist/ui_utils.js +1033 -0
  19. package/{src/shared → pdfjs/dist}/util.js +301 -287
  20. package/pdfjs/dist/worker.js +62813 -0
  21. package/src/vcf-pdf-viewer.js +77 -27
  22. package/theme/lumo/vcf-pdf-viewer-styles.js +1 -1
  23. package/theme/material/vcf-pdf-viewer.js +2 -2
  24. package/src/core/.eslintrc +0 -13
  25. package/src/core/annotation.js +0 -2948
  26. package/src/core/arithmetic_decoder.js +0 -182
  27. package/src/core/ascii_85_stream.js +0 -98
  28. package/src/core/ascii_hex_stream.js +0 -79
  29. package/src/core/base_stream.js +0 -110
  30. package/src/core/bidi.js +0 -438
  31. package/src/core/calibri_factors.js +0 -308
  32. package/src/core/catalog.js +0 -1459
  33. package/src/core/ccitt.js +0 -1062
  34. package/src/core/ccitt_stream.js +0 -60
  35. package/src/core/cff_font.js +0 -116
  36. package/src/core/cff_parser.js +0 -1949
  37. package/src/core/charsets.js +0 -119
  38. package/src/core/chunked_stream.js +0 -557
  39. package/src/core/cmap.js +0 -1039
  40. package/src/core/colorspace.js +0 -1533
  41. package/src/core/core_utils.js +0 -464
  42. package/src/core/crypto.js +0 -1900
  43. package/src/core/decode_stream.js +0 -170
  44. package/src/core/decrypt_stream.js +0 -59
  45. package/src/core/default_appearance.js +0 -99
  46. package/src/core/document.js +0 -1456
  47. package/src/core/encodings.js +0 -301
  48. package/src/core/evaluator.js +0 -4601
  49. package/src/core/file_spec.js +0 -108
  50. package/src/core/flate_stream.js +0 -402
  51. package/src/core/font_renderer.js +0 -882
  52. package/src/core/fonts.js +0 -3260
  53. package/src/core/fonts_utils.js +0 -221
  54. package/src/core/function.js +0 -1257
  55. package/src/core/glyf.js +0 -706
  56. package/src/core/glyphlist.js +0 -4558
  57. package/src/core/helvetica_factors.js +0 -353
  58. package/src/core/image.js +0 -802
  59. package/src/core/image_utils.js +0 -291
  60. package/src/core/jbig2.js +0 -2572
  61. package/src/core/jbig2_stream.js +0 -73
  62. package/src/core/jpeg_stream.js +0 -105
  63. package/src/core/jpg.js +0 -1416
  64. package/src/core/jpx.js +0 -2343
  65. package/src/core/jpx_stream.js +0 -87
  66. package/src/core/liberationsans_widths.js +0 -221
  67. package/src/core/lzw_stream.js +0 -150
  68. package/src/core/metadata_parser.js +0 -146
  69. package/src/core/metrics.js +0 -2970
  70. package/src/core/murmurhash3.js +0 -139
  71. package/src/core/myriadpro_factors.js +0 -290
  72. package/src/core/name_number_tree.js +0 -153
  73. package/src/core/object_loader.js +0 -149
  74. package/src/core/opentype_file_builder.js +0 -154
  75. package/src/core/operator_list.js +0 -734
  76. package/src/core/parser.js +0 -1416
  77. package/src/core/pattern.js +0 -985
  78. package/src/core/pdf_manager.js +0 -217
  79. package/src/core/predictor_stream.js +0 -238
  80. package/src/core/primitives.js +0 -402
  81. package/src/core/ps_parser.js +0 -272
  82. package/src/core/run_length_stream.js +0 -61
  83. package/src/core/segoeui_factors.js +0 -308
  84. package/src/core/standard_fonts.js +0 -817
  85. package/src/core/stream.js +0 -103
  86. package/src/core/struct_tree.js +0 -335
  87. package/src/core/to_unicode_map.js +0 -103
  88. package/src/core/type1_font.js +0 -421
  89. package/src/core/type1_parser.js +0 -776
  90. package/src/core/unicode.js +0 -1649
  91. package/src/core/worker.js +0 -848
  92. package/src/core/worker_stream.js +0 -135
  93. package/src/core/writer.js +0 -278
  94. package/src/core/xfa/bind.js +0 -652
  95. package/src/core/xfa/builder.js +0 -207
  96. package/src/core/xfa/config.js +0 -1926
  97. package/src/core/xfa/connection_set.js +0 -202
  98. package/src/core/xfa/data.js +0 -82
  99. package/src/core/xfa/datasets.js +0 -76
  100. package/src/core/xfa/factory.js +0 -111
  101. package/src/core/xfa/fonts.js +0 -181
  102. package/src/core/xfa/formcalc_lexer.js +0 -385
  103. package/src/core/xfa/formcalc_parser.js +0 -1340
  104. package/src/core/xfa/html_utils.js +0 -639
  105. package/src/core/xfa/layout.js +0 -383
  106. package/src/core/xfa/locale_set.js +0 -345
  107. package/src/core/xfa/namespaces.js +0 -81
  108. package/src/core/xfa/parser.js +0 -184
  109. package/src/core/xfa/setup.js +0 -38
  110. package/src/core/xfa/signature.js +0 -40
  111. package/src/core/xfa/som.js +0 -338
  112. package/src/core/xfa/stylesheet.js +0 -40
  113. package/src/core/xfa/template.js +0 -6260
  114. package/src/core/xfa/text.js +0 -290
  115. package/src/core/xfa/unknown.js +0 -29
  116. package/src/core/xfa/utils.js +0 -217
  117. package/src/core/xfa/xdp.js +0 -59
  118. package/src/core/xfa/xfa_object.js +0 -1130
  119. package/src/core/xfa/xhtml.js +0 -543
  120. package/src/core/xfa_fonts.js +0 -208
  121. package/src/core/xml_parser.js +0 -507
  122. package/src/core/xref.js +0 -899
  123. package/src/display/annotation_layer.js +0 -2107
  124. package/src/display/annotation_storage.js +0 -113
  125. package/src/display/api.js +0 -3292
  126. package/src/display/base_factory.js +0 -180
  127. package/src/display/canvas.js +0 -2828
  128. package/src/display/font_loader.js +0 -484
  129. package/src/display/metadata.js +0 -41
  130. package/src/display/network_utils.js +0 -100
  131. package/src/display/node_utils.js +0 -83
  132. package/src/display/optional_content_config.js +0 -189
  133. package/src/display/pattern_helper.js +0 -659
  134. package/src/display/svg.js +0 -1709
  135. package/src/display/text_layer.js +0 -847
  136. package/src/display/transport_stream.js +0 -303
  137. package/src/display/worker_options.js +0 -40
  138. package/src/display/xfa_layer.js +0 -204
  139. package/src/doc_helper.js +0 -25
  140. package/src/images/logo.svg +0 -41
  141. package/src/interfaces.js +0 -169
  142. package/src/license_header.js +0 -14
  143. package/src/license_header_libre.js +0 -21
  144. package/src/pdf.image_decoders.js +0 -46
  145. package/src/pdf.js +0 -146
  146. package/src/pdf.sandbox.external.js +0 -181
  147. package/src/pdf.sandbox.js +0 -151
  148. package/src/pdf.scripting.js +0 -25
  149. package/src/pdf.worker.entry.js +0 -19
  150. package/src/pdf.worker.js +0 -23
  151. package/src/scripting_api/aform.js +0 -608
  152. package/src/scripting_api/app.js +0 -621
  153. package/src/scripting_api/color.js +0 -129
  154. package/src/scripting_api/common.js +0 -58
  155. package/src/scripting_api/console.js +0 -38
  156. package/src/scripting_api/constants.js +0 -208
  157. package/src/scripting_api/doc.js +0 -1195
  158. package/src/scripting_api/error.js +0 -23
  159. package/src/scripting_api/event.js +0 -232
  160. package/src/scripting_api/field.js +0 -620
  161. package/src/scripting_api/fullscreen.js +0 -145
  162. package/src/scripting_api/initialization.js +0 -223
  163. package/src/scripting_api/pdf_object.js +0 -24
  164. package/src/scripting_api/print_params.js +0 -146
  165. package/src/scripting_api/proxy.js +0 -139
  166. package/src/scripting_api/thermometer.js +0 -69
  167. package/src/scripting_api/util.js +0 -581
  168. package/src/shared/.eslintrc +0 -13
  169. package/src/shared/cffStandardStrings.js +0 -311
  170. package/src/shared/compatibility.js +0 -114
  171. package/src/shared/fonts_utils.js +0 -429
  172. package/src/shared/is_node.js +0 -27
  173. package/src/shared/scripting_utils.js +0 -85
  174. package/src/worker_loader.js +0 -32
package/src/core/bidi.js DELETED
@@ -1,438 +0,0 @@
1
- /* Copyright 2012 Mozilla Foundation
2
- *
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- import { warn } from "../shared/util.js";
17
-
18
- // Character types for symbols from 0000 to 00FF.
19
- // Source: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
20
- // prettier-ignore
21
- const baseTypes = [
22
- "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "S", "B", "S",
23
- "WS", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN",
24
- "BN", "BN", "BN", "BN", "B", "B", "B", "S", "WS", "ON", "ON", "ET",
25
- "ET", "ET", "ON", "ON", "ON", "ON", "ON", "ES", "CS", "ES", "CS", "CS",
26
- "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "ON",
27
- "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L",
28
- "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
29
- "L", "L", "L", "L", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L",
30
- "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
31
- "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON",
32
- "BN", "BN", "BN", "BN", "BN", "BN", "B", "BN", "BN", "BN", "BN", "BN",
33
- "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN",
34
- "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "CS", "ON", "ET",
35
- "ET", "ET", "ET", "ON", "ON", "ON", "ON", "L", "ON", "ON", "BN", "ON",
36
- "ON", "ET", "ET", "EN", "EN", "ON", "L", "ON", "ON", "ON", "EN", "L",
37
- "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L",
38
- "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
39
- "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
40
- "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
41
- "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L"
42
- ];
43
-
44
- // Character types for symbols from 0600 to 06FF.
45
- // Source: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
46
- // Note that 061D does not exist in the Unicode standard (see
47
- // http://unicode.org/charts/PDF/U0600.pdf), so we replace it with an
48
- // empty string and issue a warning if we encounter this character. The
49
- // empty string is required to properly index the items after it.
50
- // prettier-ignore
51
- const arabicTypes = [
52
- "AN", "AN", "AN", "AN", "AN", "AN", "ON", "ON", "AL", "ET", "ET", "AL",
53
- "CS", "AL", "ON", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM",
54
- "NSM", "NSM", "NSM", "NSM", "AL", "AL", "", "AL", "AL", "AL", "AL", "AL",
55
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
56
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
57
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
58
- "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM",
59
- "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM",
60
- "NSM", "NSM", "NSM", "NSM", "AN", "AN", "AN", "AN", "AN", "AN", "AN",
61
- "AN", "AN", "AN", "ET", "AN", "AN", "AL", "AL", "AL", "NSM", "AL", "AL",
62
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
63
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
64
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
65
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
66
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
67
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
68
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
69
- "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL",
70
- "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN",
71
- "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "NSM", "NSM",
72
- "ON", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "EN", "EN", "EN", "EN",
73
- "EN", "EN", "EN", "EN", "EN", "EN", "AL", "AL", "AL", "AL", "AL", "AL"
74
- ];
75
-
76
- function isOdd(i) {
77
- return (i & 1) !== 0;
78
- }
79
-
80
- function isEven(i) {
81
- return (i & 1) === 0;
82
- }
83
-
84
- function findUnequal(arr, start, value) {
85
- let j, jj;
86
- for (j = start, jj = arr.length; j < jj; ++j) {
87
- if (arr[j] !== value) {
88
- return j;
89
- }
90
- }
91
- return j;
92
- }
93
-
94
- function setValues(arr, start, end, value) {
95
- for (let j = start; j < end; ++j) {
96
- arr[j] = value;
97
- }
98
- }
99
-
100
- function reverseValues(arr, start, end) {
101
- for (let i = start, j = end - 1; i < j; ++i, --j) {
102
- const temp = arr[i];
103
- arr[i] = arr[j];
104
- arr[j] = temp;
105
- }
106
- }
107
-
108
- function createBidiText(str, isLTR, vertical = false) {
109
- let dir = "ltr";
110
- if (vertical) {
111
- dir = "ttb";
112
- } else if (!isLTR) {
113
- dir = "rtl";
114
- }
115
- return { str, dir };
116
- }
117
-
118
- // These are used in bidi(), which is called frequently. We re-use them on
119
- // each call to avoid unnecessary allocations.
120
- const chars = [];
121
- const types = [];
122
-
123
- function bidi(str, startLevel, vertical) {
124
- let isLTR = true;
125
- const strLength = str.length;
126
- if (strLength === 0 || vertical) {
127
- return createBidiText(str, isLTR, vertical);
128
- }
129
-
130
- // Get types and fill arrays
131
- chars.length = strLength;
132
- types.length = strLength;
133
- let numBidi = 0;
134
-
135
- let i, ii;
136
- for (i = 0; i < strLength; ++i) {
137
- chars[i] = str.charAt(i);
138
-
139
- const charCode = str.charCodeAt(i);
140
- let charType = "L";
141
- if (charCode <= 0x00ff) {
142
- charType = baseTypes[charCode];
143
- } else if (0x0590 <= charCode && charCode <= 0x05f4) {
144
- charType = "R";
145
- } else if (0x0600 <= charCode && charCode <= 0x06ff) {
146
- charType = arabicTypes[charCode & 0xff];
147
- if (!charType) {
148
- warn("Bidi: invalid Unicode character " + charCode.toString(16));
149
- }
150
- } else if (0x0700 <= charCode && charCode <= 0x08ac) {
151
- charType = "AL";
152
- }
153
- if (charType === "R" || charType === "AL" || charType === "AN") {
154
- numBidi++;
155
- }
156
- types[i] = charType;
157
- }
158
-
159
- // Detect the bidi method
160
- // - If there are no rtl characters then no bidi needed
161
- // - If less than 30% chars are rtl then string is primarily ltr
162
- // - If more than 30% chars are rtl then string is primarily rtl
163
- if (numBidi === 0) {
164
- isLTR = true;
165
- return createBidiText(str, isLTR);
166
- }
167
-
168
- if (startLevel === -1) {
169
- if (numBidi / strLength < 0.3) {
170
- isLTR = true;
171
- startLevel = 0;
172
- } else {
173
- isLTR = false;
174
- startLevel = 1;
175
- }
176
- }
177
-
178
- const levels = [];
179
- for (i = 0; i < strLength; ++i) {
180
- levels[i] = startLevel;
181
- }
182
-
183
- /*
184
- X1-X10: skip most of this, since we are NOT doing the embeddings.
185
- */
186
- const e = isOdd(startLevel) ? "R" : "L";
187
- const sor = e;
188
- const eor = sor;
189
-
190
- /*
191
- W1. Examine each non-spacing mark (NSM) in the level run, and change the
192
- type of the NSM to the type of the previous character. If the NSM is at the
193
- start of the level run, it will get the type of sor.
194
- */
195
- let lastType = sor;
196
- for (i = 0; i < strLength; ++i) {
197
- if (types[i] === "NSM") {
198
- types[i] = lastType;
199
- } else {
200
- lastType = types[i];
201
- }
202
- }
203
-
204
- /*
205
- W2. Search backwards from each instance of a European number until the
206
- first strong type (R, L, AL, or sor) is found. If an AL is found, change
207
- the type of the European number to Arabic number.
208
- */
209
- lastType = sor;
210
- let t;
211
- for (i = 0; i < strLength; ++i) {
212
- t = types[i];
213
- if (t === "EN") {
214
- types[i] = lastType === "AL" ? "AN" : "EN";
215
- } else if (t === "R" || t === "L" || t === "AL") {
216
- lastType = t;
217
- }
218
- }
219
-
220
- /*
221
- W3. Change all ALs to R.
222
- */
223
- for (i = 0; i < strLength; ++i) {
224
- t = types[i];
225
- if (t === "AL") {
226
- types[i] = "R";
227
- }
228
- }
229
-
230
- /*
231
- W4. A single European separator between two European numbers changes to a
232
- European number. A single common separator between two numbers of the same
233
- type changes to that type:
234
- */
235
- for (i = 1; i < strLength - 1; ++i) {
236
- if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
237
- types[i] = "EN";
238
- }
239
- if (
240
- types[i] === "CS" &&
241
- (types[i - 1] === "EN" || types[i - 1] === "AN") &&
242
- types[i + 1] === types[i - 1]
243
- ) {
244
- types[i] = types[i - 1];
245
- }
246
- }
247
-
248
- /*
249
- W5. A sequence of European terminators adjacent to European numbers changes
250
- to all European numbers:
251
- */
252
- for (i = 0; i < strLength; ++i) {
253
- if (types[i] === "EN") {
254
- // do before
255
- for (let j = i - 1; j >= 0; --j) {
256
- if (types[j] !== "ET") {
257
- break;
258
- }
259
- types[j] = "EN";
260
- }
261
- // do after
262
- for (let j = i + 1; j < strLength; ++j) {
263
- if (types[j] !== "ET") {
264
- break;
265
- }
266
- types[j] = "EN";
267
- }
268
- }
269
- }
270
-
271
- /*
272
- W6. Otherwise, separators and terminators change to Other Neutral:
273
- */
274
- for (i = 0; i < strLength; ++i) {
275
- t = types[i];
276
- if (t === "WS" || t === "ES" || t === "ET" || t === "CS") {
277
- types[i] = "ON";
278
- }
279
- }
280
-
281
- /*
282
- W7. Search backwards from each instance of a European number until the
283
- first strong type (R, L, or sor) is found. If an L is found, then change
284
- the type of the European number to L.
285
- */
286
- lastType = sor;
287
- for (i = 0; i < strLength; ++i) {
288
- t = types[i];
289
- if (t === "EN") {
290
- types[i] = lastType === "L" ? "L" : "EN";
291
- } else if (t === "R" || t === "L") {
292
- lastType = t;
293
- }
294
- }
295
-
296
- /*
297
- N1. A sequence of neutrals takes the direction of the surrounding strong
298
- text if the text on both sides has the same direction. European and Arabic
299
- numbers are treated as though they were R. Start-of-level-run (sor) and
300
- end-of-level-run (eor) are used at level run boundaries.
301
- */
302
- for (i = 0; i < strLength; ++i) {
303
- if (types[i] === "ON") {
304
- const end = findUnequal(types, i + 1, "ON");
305
- let before = sor;
306
- if (i > 0) {
307
- before = types[i - 1];
308
- }
309
-
310
- let after = eor;
311
- if (end + 1 < strLength) {
312
- after = types[end + 1];
313
- }
314
- if (before !== "L") {
315
- before = "R";
316
- }
317
- if (after !== "L") {
318
- after = "R";
319
- }
320
- if (before === after) {
321
- setValues(types, i, end, before);
322
- }
323
- i = end - 1; // reset to end (-1 so next iteration is ok)
324
- }
325
- }
326
-
327
- /*
328
- N2. Any remaining neutrals take the embedding direction.
329
- */
330
- for (i = 0; i < strLength; ++i) {
331
- if (types[i] === "ON") {
332
- types[i] = e;
333
- }
334
- }
335
-
336
- /*
337
- I1. For all characters with an even (left-to-right) embedding direction,
338
- those of type R go up one level and those of type AN or EN go up two
339
- levels.
340
- I2. For all characters with an odd (right-to-left) embedding direction,
341
- those of type L, EN or AN go up one level.
342
- */
343
- for (i = 0; i < strLength; ++i) {
344
- t = types[i];
345
- if (isEven(levels[i])) {
346
- if (t === "R") {
347
- levels[i] += 1;
348
- } else if (t === "AN" || t === "EN") {
349
- levels[i] += 2;
350
- }
351
- } else {
352
- // isOdd
353
- if (t === "L" || t === "AN" || t === "EN") {
354
- levels[i] += 1;
355
- }
356
- }
357
- }
358
-
359
- /*
360
- L1. On each line, reset the embedding level of the following characters to
361
- the paragraph embedding level:
362
-
363
- segment separators,
364
- paragraph separators,
365
- any sequence of whitespace characters preceding a segment separator or
366
- paragraph separator, and any sequence of white space characters at the end
367
- of the line.
368
- */
369
-
370
- // don't bother as text is only single line
371
-
372
- /*
373
- L2. From the highest level found in the text to the lowest odd level on
374
- each line, reverse any contiguous sequence of characters that are at that
375
- level or higher.
376
- */
377
-
378
- // find highest level & lowest odd level
379
- let highestLevel = -1;
380
- let lowestOddLevel = 99;
381
- let level;
382
- for (i = 0, ii = levels.length; i < ii; ++i) {
383
- level = levels[i];
384
- if (highestLevel < level) {
385
- highestLevel = level;
386
- }
387
- if (lowestOddLevel > level && isOdd(level)) {
388
- lowestOddLevel = level;
389
- }
390
- }
391
-
392
- // now reverse between those limits
393
- for (level = highestLevel; level >= lowestOddLevel; --level) {
394
- // find segments to reverse
395
- let start = -1;
396
- for (i = 0, ii = levels.length; i < ii; ++i) {
397
- if (levels[i] < level) {
398
- if (start >= 0) {
399
- reverseValues(chars, start, i);
400
- start = -1;
401
- }
402
- } else if (start < 0) {
403
- start = i;
404
- }
405
- }
406
- if (start >= 0) {
407
- reverseValues(chars, start, levels.length);
408
- }
409
- }
410
-
411
- /*
412
- L3. Combining marks applied to a right-to-left base character will at this
413
- point precede their base character. If the rendering engine expects them to
414
- follow the base characters in the final display process, then the ordering
415
- of the marks and the base character must be reversed.
416
- */
417
-
418
- // don't bother for now
419
-
420
- /*
421
- L4. A character that possesses the mirrored property as specified by
422
- Section 4.7, Mirrored, must be depicted by a mirrored glyph if the resolved
423
- directionality of that character is R.
424
- */
425
-
426
- // don't mirror as characters are already mirrored in the pdf
427
-
428
- // Finally, return string
429
- for (i = 0, ii = chars.length; i < ii; ++i) {
430
- const ch = chars[i];
431
- if (ch === "<" || ch === ">") {
432
- chars[i] = "";
433
- }
434
- }
435
- return createBidiText(chars.join(""), isLTR);
436
- }
437
-
438
- export { bidi };