pdfjs-dist 2.0.943 → 2.4.456

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.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (192) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/README.md +4 -0
  3. package/bower.json +1 -1
  4. package/build/pdf.js +8286 -14230
  5. package/build/pdf.js.map +1 -1
  6. package/build/pdf.min.js +22 -1
  7. package/build/pdf.worker.entry.js +5 -3
  8. package/build/pdf.worker.js +25500 -26628
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25473 -0
  12. package/es5/build/pdf.js.map +1 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +57878 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/web/images/annotation-check.svg +11 -0
  17. package/es5/web/images/annotation-comment.svg +16 -0
  18. package/es5/web/images/annotation-help.svg +26 -0
  19. package/es5/web/images/annotation-insert.svg +10 -0
  20. package/es5/web/images/annotation-key.svg +11 -0
  21. package/es5/web/images/annotation-newparagraph.svg +11 -0
  22. package/es5/web/images/annotation-noicon.svg +7 -0
  23. package/es5/web/images/annotation-note.svg +42 -0
  24. package/es5/web/images/annotation-paragraph.svg +16 -0
  25. package/es5/web/images/loading-icon.gif +0 -0
  26. package/es5/web/images/shadow.png +0 -0
  27. package/es5/web/images/texture.png +0 -0
  28. package/es5/web/pdf_viewer.css +407 -0
  29. package/es5/web/pdf_viewer.js +7757 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +2887 -4094
  32. package/image_decoders/pdf.image_decoders.js.map +1 -1
  33. package/image_decoders/pdf.image_decoders.min.js +22 -1
  34. package/lib/README.md +7 -0
  35. package/lib/core/annotation.js +855 -778
  36. package/lib/core/arithmetic_decoder.js +325 -311
  37. package/lib/core/bidi.js +117 -50
  38. package/lib/core/ccitt.js +251 -89
  39. package/lib/core/ccitt_stream.js +26 -16
  40. package/lib/core/cff_parser.js +525 -197
  41. package/lib/core/charsets.js +6 -5
  42. package/lib/core/chunked_stream.js +541 -406
  43. package/lib/core/cmap.js +368 -253
  44. package/lib/core/colorspace.js +781 -800
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +609 -422
  47. package/lib/core/document.js +649 -481
  48. package/lib/core/encodings.js +33 -24
  49. package/lib/core/evaluator.js +1471 -736
  50. package/lib/core/font_renderer.js +289 -149
  51. package/lib/core/fonts.js +1067 -413
  52. package/lib/core/function.js +517 -287
  53. package/lib/core/glyphlist.js +4529 -4527
  54. package/lib/core/image.js +232 -114
  55. package/lib/core/image_utils.js +94 -0
  56. package/lib/core/jbig2.js +711 -342
  57. package/lib/core/jbig2_stream.js +31 -19
  58. package/lib/core/jpeg_stream.js +151 -26
  59. package/lib/core/jpg.js +433 -181
  60. package/lib/core/jpx.js +551 -143
  61. package/lib/core/jpx_stream.js +40 -28
  62. package/lib/core/metrics.js +2931 -2931
  63. package/lib/core/murmurhash3.js +104 -97
  64. package/lib/core/obj.js +1561 -1053
  65. package/lib/core/operator_list.js +192 -64
  66. package/lib/core/parser.js +1162 -864
  67. package/lib/core/pattern.js +224 -75
  68. package/lib/core/pdf_manager.js +154 -285
  69. package/lib/core/primitives.js +145 -69
  70. package/lib/core/ps_parser.js +212 -162
  71. package/lib/core/standard_fonts.js +245 -244
  72. package/lib/core/stream.js +353 -81
  73. package/lib/core/type1_parser.js +218 -68
  74. package/lib/core/unicode.js +1682 -1655
  75. package/lib/core/worker.js +233 -302
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +808 -862
  78. package/lib/display/api.js +1778 -1462
  79. package/lib/display/api_compatibility.js +14 -9
  80. package/lib/display/canvas.js +463 -140
  81. package/lib/display/content_disposition.js +86 -58
  82. package/lib/display/display_utils.js +524 -0
  83. package/lib/display/fetch_stream.js +202 -274
  84. package/lib/display/font_loader.js +311 -333
  85. package/lib/display/metadata.js +98 -88
  86. package/lib/display/network.js +343 -347
  87. package/lib/display/network_utils.js +46 -26
  88. package/lib/display/node_stream.js +326 -404
  89. package/lib/display/pattern_helper.js +168 -69
  90. package/lib/display/svg.js +1296 -885
  91. package/lib/display/text_layer.js +229 -103
  92. package/lib/display/transport_stream.js +290 -250
  93. package/lib/display/webgl.js +116 -83
  94. package/lib/display/worker_options.js +6 -5
  95. package/lib/display/xml_parser.js +358 -337
  96. package/lib/examples/node/domstubs.js +95 -39
  97. package/lib/pdf.js +49 -31
  98. package/lib/pdf.worker.js +7 -5
  99. package/lib/shared/compatibility.js +3 -145
  100. package/lib/shared/is_node.js +8 -7
  101. package/lib/shared/message_handler.js +367 -314
  102. package/lib/shared/util.js +421 -415
  103. package/lib/test/unit/annotation_spec.js +1570 -690
  104. package/lib/test/unit/api_spec.js +855 -493
  105. package/lib/test/unit/bidi_spec.js +12 -12
  106. package/lib/test/unit/cff_parser_spec.js +88 -61
  107. package/lib/test/unit/clitests_helper.js +9 -12
  108. package/lib/test/unit/cmap_spec.js +140 -88
  109. package/lib/test/unit/colorspace_spec.js +204 -152
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +194 -182
  112. package/lib/test/unit/custom_spec.js +50 -64
  113. package/lib/test/unit/display_svg_spec.js +53 -38
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +17 -22
  116. package/lib/test/unit/encodings_spec.js +15 -57
  117. package/lib/test/unit/evaluator_spec.js +90 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +219 -205
  120. package/lib/test/unit/jasmine-boot.js +68 -39
  121. package/lib/test/unit/message_handler_spec.js +187 -160
  122. package/lib/test/unit/metadata_spec.js +87 -34
  123. package/lib/test/unit/murmurhash3_spec.js +13 -13
  124. package/lib/test/unit/network_spec.js +26 -59
  125. package/lib/test/unit/network_utils_spec.js +187 -121
  126. package/lib/test/unit/node_stream_spec.js +98 -90
  127. package/lib/test/unit/parser_spec.js +173 -131
  128. package/lib/test/unit/pdf_find_controller_spec.js +148 -67
  129. package/lib/test/unit/pdf_find_utils_spec.js +35 -34
  130. package/lib/test/unit/pdf_history_spec.js +45 -33
  131. package/lib/test/unit/primitives_spec.js +161 -126
  132. package/lib/test/unit/stream_spec.js +22 -15
  133. package/lib/test/unit/test_utils.js +149 -98
  134. package/lib/test/unit/testreporter.js +36 -18
  135. package/lib/test/unit/type1_parser_spec.js +46 -44
  136. package/lib/test/unit/ui_utils_spec.js +388 -372
  137. package/lib/test/unit/unicode_spec.js +49 -46
  138. package/lib/test/unit/util_spec.js +144 -248
  139. package/lib/web/annotation_layer_builder.js +75 -95
  140. package/lib/web/app.js +1538 -1147
  141. package/lib/web/app_options.js +116 -104
  142. package/lib/web/base_viewer.js +950 -775
  143. package/lib/web/chromecom.js +217 -225
  144. package/lib/web/debugger.js +236 -148
  145. package/lib/web/download_manager.js +50 -50
  146. package/lib/web/firefox_print_service.js +51 -33
  147. package/lib/web/firefoxcom.js +225 -352
  148. package/lib/web/genericcom.js +30 -93
  149. package/lib/web/genericl10n.js +26 -143
  150. package/lib/web/grab_to_pan.js +57 -33
  151. package/lib/web/interfaces.js +105 -232
  152. package/lib/web/overlay_manager.js +73 -227
  153. package/lib/web/password_prompt.js +44 -62
  154. package/lib/web/pdf_attachment_viewer.js +118 -123
  155. package/lib/web/pdf_cursor_tools.js +89 -93
  156. package/lib/web/pdf_document_properties.js +242 -281
  157. package/lib/web/pdf_find_bar.js +157 -163
  158. package/lib/web/pdf_find_controller.js +598 -454
  159. package/lib/web/pdf_find_utils.js +32 -16
  160. package/lib/web/pdf_history.js +481 -355
  161. package/lib/web/pdf_link_service.js +355 -323
  162. package/lib/web/pdf_outline_viewer.js +167 -152
  163. package/lib/web/pdf_page_view.js +511 -457
  164. package/lib/web/pdf_presentation_mode.js +347 -335
  165. package/lib/web/pdf_print_service.js +133 -103
  166. package/lib/web/pdf_rendering_queue.js +98 -100
  167. package/lib/web/pdf_sidebar.js +323 -299
  168. package/lib/web/pdf_sidebar_resizer.js +107 -108
  169. package/lib/web/pdf_single_page_viewer.js +94 -146
  170. package/lib/web/pdf_thumbnail_view.js +319 -269
  171. package/lib/web/pdf_thumbnail_viewer.js +219 -199
  172. package/lib/web/pdf_viewer.component.js +111 -32
  173. package/lib/web/pdf_viewer.js +61 -101
  174. package/lib/web/preferences.js +87 -272
  175. package/lib/web/secondary_toolbar.js +207 -220
  176. package/lib/web/text_layer_builder.js +322 -322
  177. package/lib/web/toolbar.js +227 -180
  178. package/lib/web/ui_utils.js +476 -421
  179. package/lib/web/view_history.js +59 -208
  180. package/lib/web/viewer_compatibility.js +9 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +36 -22
  183. package/web/pdf_viewer.js +4407 -4516
  184. package/web/pdf_viewer.js.map +1 -1
  185. package/webpack.js +14 -5
  186. package/external/streams/streams-lib.js +0 -3962
  187. package/external/url/url-lib.js +0 -627
  188. package/lib/display/dom_utils.js +0 -441
  189. package/lib/shared/streams_polyfill.js +0 -39
  190. package/lib/shared/url_polyfill.js +0 -50
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
  192. package/lib/web/dom_events.js +0 -140
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -19,23 +19,23 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- var _bidi = require('../../core/bidi');
24
+ var _bidi = require("../../core/bidi.js");
25
25
 
26
- describe('bidi', function () {
27
- it('should mark text as RTL if more than 30% of text is RTL', function () {
28
- var test = '\u0645\u0635\u0631 Egypt';
29
- var result = 'Egypt \u0631\u0635\u0645';
26
+ describe("bidi", function () {
27
+ it("should mark text as RTL if more than 30% of text is RTL", function () {
28
+ var test = "\u0645\u0635\u0631 Egypt";
29
+ var result = "Egypt \u0631\u0635\u0645";
30
30
  var bidiText = (0, _bidi.bidi)(test, -1, false);
31
31
  expect(bidiText.str).toEqual(result);
32
- expect(bidiText.dir).toEqual('rtl');
32
+ expect(bidiText.dir).toEqual("rtl");
33
33
  });
34
- it('should mark text as LTR if less than 30% of text is RTL', function () {
35
- var test = 'Egypt is known as \u0645\u0635\u0631 in Arabic.';
36
- var result = 'Egypt is known as \u0631\u0635\u0645 in Arabic.';
34
+ it("should mark text as LTR if less than 30% of text is RTL", function () {
35
+ var test = "Egypt is known as \u0645\u0635\u0631 in Arabic.";
36
+ var result = "Egypt is known as \u0631\u0635\u0645 in Arabic.";
37
37
  var bidiText = (0, _bidi.bidi)(test, -1, false);
38
38
  expect(bidiText.str).toEqual(result);
39
- expect(bidiText.dir).toEqual('ltr');
39
+ expect(bidiText.dir).toEqual("ltr");
40
40
  });
41
41
  });
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -19,35 +19,41 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- var _cff_parser = require('../../core/cff_parser');
24
+ var _cff_parser = require("../../core/cff_parser.js");
25
25
 
26
- var _fonts = require('../../core/fonts');
26
+ var _fonts = require("../../core/fonts.js");
27
27
 
28
- var _stream = require('../../core/stream');
28
+ var _stream = require("../../core/stream.js");
29
29
 
30
- describe('CFFParser', function () {
30
+ describe("CFFParser", function () {
31
31
  function createWithNullProto(obj) {
32
32
  var result = Object.create(null);
33
+
33
34
  for (var i in obj) {
34
35
  result[i] = obj[i];
35
36
  }
37
+
36
38
  return result;
37
39
  }
40
+
38
41
  var privateDictStub = {
39
- getByName: function getByName(name) {
42
+ getByName(name) {
40
43
  return 0;
41
44
  }
45
+
42
46
  };
43
47
  var fontData, parser, cff;
44
48
  beforeAll(function (done) {
45
- var exampleFont = '0100040100010101134142434445462b' + '54696d65732d526f6d616e000101011f' + 'f81b00f81c02f81d03f819041c6f000d' + 'fb3cfb6efa7cfa1605e911b8f1120003' + '01010813183030312e30303754696d65' + '7320526f6d616e54696d657300000002' + '010102030e0e7d99f92a99fb7695f773' + '8b06f79a93fc7c8c077d99f85695f75e' + '9908fb6e8cf87393f7108b09a70adf0b' + 'f78e14';
49
+ var exampleFont = "0100040100010101134142434445462b" + "54696d65732d526f6d616e000101011f" + "f81b00f81c02f81d03f819041c6f000d" + "fb3cfb6efa7cfa1605e911b8f1120003" + "01010813183030312e30303754696d65" + "7320526f6d616e54696d657300000002" + "010102030e0e7d99f92a99fb7695f773" + "8b06f79a93fc7c8c077d99f85695f75e" + "9908fb6e8cf87393f7108b09a70adf0b" + "f78e14";
46
50
  var fontArr = [];
51
+
47
52
  for (var i = 0, ii = exampleFont.length; i < ii; i += 2) {
48
53
  var hex = exampleFont.substring(i, i + 2);
49
54
  fontArr.push(parseInt(hex, 16));
50
55
  }
56
+
51
57
  fontData = new _stream.Stream(fontArr);
52
58
  done();
53
59
  });
@@ -63,54 +69,56 @@ describe('CFFParser', function () {
63
69
  parser = cff = null;
64
70
  done();
65
71
  });
66
- it('parses header', function () {
72
+ it("parses header", function () {
67
73
  var header = cff.header;
68
74
  expect(header.major).toEqual(1);
69
75
  expect(header.minor).toEqual(0);
70
76
  expect(header.hdrSize).toEqual(4);
71
77
  expect(header.offSize).toEqual(1);
72
78
  });
73
- it('parses name index', function () {
79
+ it("parses name index", function () {
74
80
  var names = cff.names;
75
81
  expect(names.length).toEqual(1);
76
- expect(names[0]).toEqual('ABCDEF+Times-Roman');
82
+ expect(names[0]).toEqual("ABCDEF+Times-Roman");
77
83
  });
78
- it('parses string index', function () {
84
+ it("parses string index", function () {
79
85
  var strings = cff.strings;
80
86
  expect(strings.count).toEqual(3);
81
- expect(strings.get(0)).toEqual('.notdef');
82
- expect(strings.get(391)).toEqual('001.007');
87
+ expect(strings.get(0)).toEqual(".notdef");
88
+ expect(strings.get(391)).toEqual("001.007");
83
89
  });
84
- it('parses top dict', function () {
90
+ it("parses top dict", function () {
85
91
  var topDict = cff.topDict;
86
- expect(topDict.getByName('version')).toEqual(391);
87
- expect(topDict.getByName('FullName')).toEqual(392);
88
- expect(topDict.getByName('FamilyName')).toEqual(393);
89
- expect(topDict.getByName('Weight')).toEqual(389);
90
- expect(topDict.getByName('UniqueID')).toEqual(28416);
91
- expect(topDict.getByName('FontBBox')).toEqual([-168, -218, 1000, 898]);
92
- expect(topDict.getByName('CharStrings')).toEqual(94);
93
- expect(topDict.getByName('Private')).toEqual([45, 102]);
92
+ expect(topDict.getByName("version")).toEqual(391);
93
+ expect(topDict.getByName("FullName")).toEqual(392);
94
+ expect(topDict.getByName("FamilyName")).toEqual(393);
95
+ expect(topDict.getByName("Weight")).toEqual(389);
96
+ expect(topDict.getByName("UniqueID")).toEqual(28416);
97
+ expect(topDict.getByName("FontBBox")).toEqual([-168, -218, 1000, 898]);
98
+ expect(topDict.getByName("CharStrings")).toEqual(94);
99
+ expect(topDict.getByName("Private")).toEqual([45, 102]);
94
100
  });
95
- it('refuses to add topDict key with invalid value (bug 1068432)', function () {
101
+ it("refuses to add topDict key with invalid value (bug 1068432)", function () {
96
102
  var topDict = cff.topDict;
97
- var defaultValue = topDict.getByName('UnderlinePosition');
103
+ var defaultValue = topDict.getByName("UnderlinePosition");
98
104
  topDict.setByKey(3075, [NaN]);
99
- expect(topDict.getByName('UnderlinePosition')).toEqual(defaultValue);
105
+ expect(topDict.getByName("UnderlinePosition")).toEqual(defaultValue);
100
106
  });
101
- it('ignores reserved commands in parseDict, and refuses to add privateDict ' + 'keys with invalid values (bug 1308536)', function () {
107
+ it("ignores reserved commands in parseDict, and refuses to add privateDict " + "keys with invalid values (bug 1308536)", function () {
102
108
  var bytes = new Uint8Array([64, 39, 31, 30, 252, 114, 137, 115, 79, 30, 197, 119, 2, 99, 127, 6]);
103
109
  parser.bytes = bytes;
104
110
  var topDict = cff.topDict;
105
- topDict.setByName('Private', [bytes.length, 0]);
106
- var parsePrivateDict = function parsePrivateDict() {
111
+ topDict.setByName("Private", [bytes.length, 0]);
112
+
113
+ var parsePrivateDict = function () {
107
114
  parser.parsePrivateDict(topDict);
108
115
  };
116
+
109
117
  expect(parsePrivateDict).not.toThrow();
110
118
  var privateDict = topDict.privateDict;
111
- expect(privateDict.getByName('BlueValues')).toBeNull();
119
+ expect(privateDict.getByName("BlueValues")).toBeNull();
112
120
  });
113
- it('parses a CharString having cntrmask', function () {
121
+ it("parses a CharString having cntrmask", function () {
114
122
  var bytes = new Uint8Array([0, 1, 1, 0, 38, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 1, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 3, 20, 22, 22, 14]);
115
123
  parser.bytes = bytes;
116
124
  var charStringsIndex = parser.parseIndex(0).obj;
@@ -121,7 +129,7 @@ describe('CFFParser', function () {
121
129
  expect(charStrings.count).toEqual(1);
122
130
  expect(charStrings.get(0).length).toEqual(38);
123
131
  });
124
- it('parses a CharString endchar with 4 args w/seac enabled', function () {
132
+ it("parses a CharString endchar with 4 args w/seac enabled", function () {
125
133
  var parser = new _cff_parser.CFFParser(fontData, {}, true);
126
134
  parser.parse();
127
135
  var bytes = new Uint8Array([0, 1, 1, 0, 237, 247, 22, 247, 72, 204, 247, 86, 14]);
@@ -140,7 +148,7 @@ describe('CFFParser', function () {
140
148
  expect(result.seacs[0][2]).toEqual(65);
141
149
  expect(result.seacs[0][3]).toEqual(194);
142
150
  });
143
- it('parses a CharString endchar with 4 args w/seac disabled', function () {
151
+ it("parses a CharString endchar with 4 args w/seac disabled", function () {
144
152
  var parser = new _cff_parser.CFFParser(fontData, {}, false);
145
153
  parser.parse();
146
154
  var bytes = new Uint8Array([0, 1, 1, 0, 237, 247, 22, 247, 72, 204, 247, 86, 14]);
@@ -154,7 +162,7 @@ describe('CFFParser', function () {
154
162
  expect(result.charStrings.get(0).length).toEqual(9);
155
163
  expect(result.seacs.length).toEqual(0);
156
164
  });
157
- it('parses a CharString endchar no args', function () {
165
+ it("parses a CharString endchar no args", function () {
158
166
  var bytes = new Uint8Array([0, 1, 1, 0, 14]);
159
167
  parser.bytes = bytes;
160
168
  var charStringsIndex = parser.parseIndex(0).obj;
@@ -166,41 +174,43 @@ describe('CFFParser', function () {
166
174
  expect(result.charStrings.get(0)[0]).toEqual(14);
167
175
  expect(result.seacs.length).toEqual(0);
168
176
  });
169
- it('parses predefined charsets', function () {
177
+ it("parses predefined charsets", function () {
170
178
  var charset = parser.parseCharsets(0, 0, null, true);
171
179
  expect(charset.predefined).toEqual(true);
172
180
  });
173
- it('parses charset format 0', function () {
181
+ it("parses charset format 0", function () {
174
182
  var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x00, 0x00, 0x02]);
175
183
  parser.bytes = bytes;
176
184
  var charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), false);
177
- expect(charset.charset[1]).toEqual('exclam');
185
+ expect(charset.charset[1]).toEqual("exclam");
178
186
  charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), true);
179
187
  expect(charset.charset[1]).toEqual(2);
180
188
  });
181
- it('parses charset format 1', function () {
189
+ it("parses charset format 1", function () {
182
190
  var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x01]);
183
191
  parser.bytes = bytes;
184
192
  var charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), false);
185
- expect(charset.charset).toEqual(['.notdef', 'quoteright', 'parenleft']);
193
+ expect(charset.charset).toEqual([".notdef", "quoteright", "parenleft"]);
186
194
  charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), true);
187
- expect(charset.charset).toEqual(['.notdef', 8, 9]);
195
+ expect(charset.charset).toEqual([".notdef", 8, 9]);
188
196
  });
189
- it('parses charset format 2', function () {
197
+ it("parses charset format 2", function () {
190
198
  var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x01]);
191
199
  parser.bytes = bytes;
192
200
  var charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), false);
193
- expect(charset.charset).toEqual(['.notdef', 'quoteright', 'parenleft']);
201
+ expect(charset.charset).toEqual([".notdef", "quoteright", "parenleft"]);
194
202
  charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), true);
195
- expect(charset.charset).toEqual(['.notdef', 8, 9]);
203
+ expect(charset.charset).toEqual([".notdef", 8, 9]);
196
204
  });
197
- it('parses encoding format 0', function () {
205
+ it("parses encoding format 0", function () {
198
206
  var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x01, 0x08]);
199
207
  parser.bytes = bytes;
200
208
  var encoding = parser.parseEncoding(2, {}, new _cff_parser.CFFStrings(), null);
201
- expect(encoding.encoding).toEqual(createWithNullProto({ 0x8: 1 }));
209
+ expect(encoding.encoding).toEqual(createWithNullProto({
210
+ 0x8: 1
211
+ }));
202
212
  });
203
- it('parses encoding format 1', function () {
213
+ it("parses encoding format 1", function () {
204
214
  var bytes = new Uint8Array([0x00, 0x00, 0x01, 0x01, 0x07, 0x01]);
205
215
  parser.bytes = bytes;
206
216
  var encoding = parser.parseEncoding(2, {}, new _cff_parser.CFFStrings(), null);
@@ -209,21 +219,21 @@ describe('CFFParser', function () {
209
219
  0x08: 0x02
210
220
  }));
211
221
  });
212
- it('parses fdselect format 0', function () {
222
+ it("parses fdselect format 0", function () {
213
223
  var bytes = new Uint8Array([0x00, 0x00, 0x01]);
214
224
  parser.bytes = bytes.slice();
215
225
  var fdSelect = parser.parseFDSelect(0, 2);
216
226
  expect(fdSelect.fdSelect).toEqual([0, 1]);
217
227
  expect(fdSelect.format).toEqual(0);
218
228
  });
219
- it('parses fdselect format 3', function () {
229
+ it("parses fdselect format 3", function () {
220
230
  var bytes = new Uint8Array([0x03, 0x00, 0x02, 0x00, 0x00, 0x09, 0x00, 0x02, 0x0a, 0x00, 0x04]);
221
231
  parser.bytes = bytes.slice();
222
232
  var fdSelect = parser.parseFDSelect(0, 4);
223
233
  expect(fdSelect.fdSelect).toEqual([9, 9, 0xa, 0xa]);
224
234
  expect(fdSelect.format).toEqual(3);
225
235
  });
226
- it('parses invalid fdselect format 3 (bug 1146106)', function () {
236
+ it("parses invalid fdselect format 3 (bug 1146106)", function () {
227
237
  var bytes = new Uint8Array([0x03, 0x00, 0x02, 0x00, 0x01, 0x09, 0x00, 0x02, 0x0a, 0x00, 0x04]);
228
238
  parser.bytes = bytes.slice();
229
239
  var fdSelect = parser.parseFDSelect(0, 4);
@@ -231,16 +241,17 @@ describe('CFFParser', function () {
231
241
  expect(fdSelect.format).toEqual(3);
232
242
  });
233
243
  });
234
- describe('CFFCompiler', function () {
244
+ describe("CFFCompiler", function () {
235
245
  function testParser(bytes) {
236
246
  bytes = new Uint8Array(bytes);
237
247
  return new _cff_parser.CFFParser({
238
- getBytes: function getBytes() {
248
+ getBytes: () => {
239
249
  return bytes;
240
250
  }
241
251
  }, {}, _fonts.SEAC_ANALYSIS_ENABLED);
242
252
  }
243
- it('encodes integers', function () {
253
+
254
+ it("encodes integers", function () {
244
255
  var c = new _cff_parser.CFFCompiler();
245
256
  expect(c.encodeInteger(0)).toEqual([0x8b]);
246
257
  expect(c.encodeInteger(100)).toEqual([0xef]);
@@ -252,44 +263,60 @@ describe('CFFCompiler', function () {
252
263
  expect(c.encodeInteger(100000)).toEqual([0x1d, 0x00, 0x01, 0x86, 0xa0]);
253
264
  expect(c.encodeInteger(-100000)).toEqual([0x1d, 0xff, 0xfe, 0x79, 0x60]);
254
265
  });
255
- it('encodes floats', function () {
266
+ it("encodes floats", function () {
256
267
  var c = new _cff_parser.CFFCompiler();
257
268
  expect(c.encodeFloat(-2.25)).toEqual([0x1e, 0xe2, 0xa2, 0x5f]);
258
269
  expect(c.encodeFloat(5e-11)).toEqual([0x1e, 0x5c, 0x11, 0xff]);
259
270
  });
260
- it('sanitizes name index', function () {
271
+ it("sanitizes name index", function () {
261
272
  var c = new _cff_parser.CFFCompiler();
262
- var nameIndexCompiled = c.compileNameIndex(['[a']);
273
+ var nameIndexCompiled = c.compileNameIndex(["[a"]);
263
274
  var parser = testParser(nameIndexCompiled);
264
275
  var nameIndex = parser.parseIndex(0);
265
276
  var names = parser.parseNameIndex(nameIndex.obj);
266
- expect(names).toEqual(['_a']);
267
- var longName = '';
277
+ expect(names).toEqual(["_a"]);
278
+ var longName = "";
279
+
268
280
  for (var i = 0; i < 129; i++) {
269
- longName += '_';
281
+ longName += "_";
270
282
  }
283
+
271
284
  nameIndexCompiled = c.compileNameIndex([longName]);
272
285
  parser = testParser(nameIndexCompiled);
273
286
  nameIndex = parser.parseIndex(0);
274
287
  names = parser.parseNameIndex(nameIndex.obj);
275
288
  expect(names[0].length).toEqual(127);
276
289
  });
277
- it('compiles fdselect format 0', function () {
290
+ it("compiles fdselect format 0", function () {
278
291
  var fdSelect = new _cff_parser.CFFFDSelect(0, [3, 2, 1]);
279
292
  var c = new _cff_parser.CFFCompiler();
280
293
  var out = c.compileFDSelect(fdSelect);
281
294
  expect(out).toEqual([0, 3, 2, 1]);
282
295
  });
283
- it('compiles fdselect format 3', function () {
296
+ it("compiles fdselect format 3", function () {
284
297
  var fdSelect = new _cff_parser.CFFFDSelect(3, [0, 0, 1, 1]);
285
298
  var c = new _cff_parser.CFFCompiler();
286
299
  var out = c.compileFDSelect(fdSelect);
287
300
  expect(out).toEqual([3, 0, 2, 0, 0, 0, 0, 2, 1, 0, 4]);
288
301
  });
289
- it('compiles fdselect format 3, single range', function () {
302
+ it("compiles fdselect format 3, single range", function () {
290
303
  var fdSelect = new _cff_parser.CFFFDSelect(3, [0, 0]);
291
304
  var c = new _cff_parser.CFFCompiler();
292
305
  var out = c.compileFDSelect(fdSelect);
293
306
  expect(out).toEqual([3, 0, 1, 0, 0, 0, 0, 2]);
294
307
  });
308
+ it("compiles charset of CID font", function () {
309
+ var charset = new _cff_parser.CFFCharset();
310
+ var c = new _cff_parser.CFFCompiler();
311
+ var numGlyphs = 7;
312
+ var out = c.compileCharset(charset, numGlyphs, new _cff_parser.CFFStrings(), true);
313
+ expect(out).toEqual([2, 0, 0, 0, numGlyphs - 1]);
314
+ });
315
+ it("compiles charset of non CID font", function () {
316
+ var charset = new _cff_parser.CFFCharset(false, 0, ["space", "exclam"]);
317
+ var c = new _cff_parser.CFFCompiler();
318
+ var numGlyphs = 3;
319
+ var out = c.compileCharset(charset, numGlyphs, new _cff_parser.CFFStrings(), false);
320
+ expect(out).toEqual([0, 0, 1, 0, 2]);
321
+ });
295
322
  });
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -19,23 +19,20 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- var _util = require('../../shared/util');
24
+ var _util = require("../../shared/util.js");
25
25
 
26
- var _is_node = require('../../shared/is_node');
26
+ var _is_node = require("../../shared/is_node.js");
27
27
 
28
- var _is_node2 = _interopRequireDefault(_is_node);
28
+ var _node_stream = require("../../display/node_stream.js");
29
29
 
30
- var _node_stream = require('../../display/node_stream');
30
+ var _api = require("../../display/api.js");
31
31
 
32
- var _api = require('../../display/api');
33
-
34
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
-
36
- if (!(0, _is_node2.default)()) {
37
- throw new Error('The `gulp unittestcli` command can only be used in ' + 'Node.js environments.');
32
+ if (!_is_node.isNodeJS) {
33
+ throw new Error("The `gulp unittestcli` command can only be used in " + "Node.js environments.");
38
34
  }
35
+
39
36
  (0, _util.setVerbosityLevel)(_util.VerbosityLevel.ERRORS);
40
37
  (0, _api.setPDFNetworkStreamFactory)(function (params) {
41
38
  return new _node_stream.PDFNodeStream(params);