pdfjs-dist 2.1.266 → 2.5.207

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 (191) 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 +8382 -18492
  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 +20417 -29816
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25688 -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 +58239 -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 +403 -0
  29. package/es5/web/pdf_viewer.js +7742 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +1475 -4897
  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 +750 -899
  36. package/lib/core/arithmetic_decoder.js +81 -97
  37. package/lib/core/bidi.js +54 -46
  38. package/lib/core/ccitt.js +88 -81
  39. package/lib/core/ccitt_stream.js +15 -14
  40. package/lib/core/cff_parser.js +235 -183
  41. package/lib/core/charsets.js +4 -4
  42. package/lib/core/chunked_stream.js +447 -542
  43. package/lib/core/cmap.js +222 -264
  44. package/lib/core/colorspace.js +699 -863
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +379 -437
  47. package/lib/core/document.js +573 -660
  48. package/lib/core/encodings.js +15 -15
  49. package/lib/core/evaluator.js +1103 -868
  50. package/lib/core/font_renderer.js +135 -178
  51. package/lib/core/fonts.js +570 -491
  52. package/lib/core/function.js +291 -288
  53. package/lib/core/glyphlist.js +4527 -4526
  54. package/lib/core/image.js +145 -149
  55. package/lib/core/image_utils.js +170 -0
  56. package/lib/core/jbig2.js +325 -316
  57. package/lib/core/jbig2_stream.js +18 -17
  58. package/lib/core/jpeg_stream.js +21 -26
  59. package/lib/core/jpg.js +284 -232
  60. package/lib/core/jpx.js +161 -143
  61. package/lib/core/jpx_stream.js +28 -28
  62. package/lib/core/metrics.js +2929 -2929
  63. package/lib/core/murmurhash3.js +90 -101
  64. package/lib/core/obj.js +1183 -1157
  65. package/lib/core/operator_list.js +99 -67
  66. package/lib/core/parser.js +972 -911
  67. package/lib/core/pattern.js +87 -70
  68. package/lib/core/pdf_manager.js +150 -315
  69. package/lib/core/primitives.js +83 -56
  70. package/lib/core/ps_parser.js +175 -214
  71. package/lib/core/standard_fonts.js +237 -236
  72. package/lib/core/stream.js +94 -74
  73. package/lib/core/type1_parser.js +87 -69
  74. package/lib/core/unicode.js +1654 -1654
  75. package/lib/core/worker.js +193 -390
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +741 -972
  78. package/lib/display/api.js +1500 -1791
  79. package/lib/display/api_compatibility.js +12 -17
  80. package/lib/display/canvas.js +165 -165
  81. package/lib/display/content_disposition.js +40 -59
  82. package/lib/display/display_utils.js +515 -0
  83. package/lib/display/fetch_stream.js +183 -298
  84. package/lib/display/font_loader.js +273 -413
  85. package/lib/display/metadata.js +86 -98
  86. package/lib/display/network.js +266 -359
  87. package/lib/display/network_utils.js +25 -18
  88. package/lib/display/node_stream.js +285 -458
  89. package/lib/display/pattern_helper.js +113 -65
  90. package/lib/display/svg.js +1166 -901
  91. package/lib/display/text_layer.js +156 -132
  92. package/lib/display/transport_stream.js +262 -278
  93. package/lib/display/webgl.js +70 -83
  94. package/lib/display/worker_options.js +3 -3
  95. package/lib/display/xml_parser.js +303 -392
  96. package/lib/examples/node/domstubs.js +40 -37
  97. package/lib/pdf.js +226 -59
  98. package/lib/pdf.worker.js +14 -6
  99. package/lib/shared/compatibility.js +3 -246
  100. package/lib/shared/is_node.js +7 -6
  101. package/lib/shared/message_handler.js +327 -332
  102. package/lib/shared/util.js +266 -416
  103. package/lib/test/unit/annotation_spec.js +1555 -701
  104. package/lib/test/unit/api_spec.js +802 -604
  105. package/lib/test/unit/bidi_spec.js +7 -7
  106. package/lib/test/unit/cff_parser_spec.js +84 -69
  107. package/lib/test/unit/clitests_helper.js +7 -9
  108. package/lib/test/unit/cmap_spec.js +74 -76
  109. package/lib/test/unit/colorspace_spec.js +166 -161
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +181 -181
  112. package/lib/test/unit/custom_spec.js +20 -22
  113. package/lib/test/unit/display_svg_spec.js +34 -39
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +16 -21
  116. package/lib/test/unit/encodings_spec.js +12 -34
  117. package/lib/test/unit/evaluator_spec.js +83 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +206 -204
  120. package/lib/test/unit/jasmine-boot.js +46 -30
  121. package/lib/test/unit/message_handler_spec.js +173 -159
  122. package/lib/test/unit/metadata_spec.js +69 -69
  123. package/lib/test/unit/murmurhash3_spec.js +12 -12
  124. package/lib/test/unit/network_spec.js +13 -61
  125. package/lib/test/unit/network_utils_spec.js +183 -119
  126. package/lib/test/unit/node_stream_spec.js +78 -92
  127. package/lib/test/unit/parser_spec.js +172 -114
  128. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  129. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  130. package/lib/test/unit/pdf_history_spec.js +32 -32
  131. package/lib/test/unit/primitives_spec.js +140 -125
  132. package/lib/test/unit/stream_spec.js +16 -14
  133. package/lib/test/unit/test_utils.js +131 -143
  134. package/lib/test/unit/testreporter.js +19 -19
  135. package/lib/test/unit/type1_parser_spec.js +42 -42
  136. package/lib/test/unit/ui_utils_spec.js +297 -459
  137. package/lib/test/unit/unicode_spec.js +38 -38
  138. package/lib/test/unit/util_spec.js +121 -305
  139. package/lib/web/annotation_layer_builder.js +66 -103
  140. package/lib/web/app.js +1328 -1214
  141. package/lib/web/app_options.js +105 -107
  142. package/lib/web/base_viewer.js +824 -838
  143. package/lib/web/chromecom.js +165 -252
  144. package/lib/web/debugger.js +149 -205
  145. package/lib/web/download_manager.js +39 -55
  146. package/lib/web/firefox_print_service.js +37 -27
  147. package/lib/web/firefoxcom.js +212 -363
  148. package/lib/web/genericcom.js +26 -108
  149. package/lib/web/genericl10n.js +24 -153
  150. package/lib/web/grab_to_pan.js +32 -30
  151. package/lib/web/interfaces.js +80 -254
  152. package/lib/web/overlay_manager.js +70 -246
  153. package/lib/web/password_prompt.js +38 -64
  154. package/lib/web/pdf_attachment_viewer.js +113 -131
  155. package/lib/web/pdf_cursor_tools.js +75 -102
  156. package/lib/web/pdf_document_properties.js +221 -306
  157. package/lib/web/pdf_find_bar.js +136 -170
  158. package/lib/web/pdf_find_controller.js +491 -548
  159. package/lib/web/pdf_find_utils.js +13 -13
  160. package/lib/web/pdf_history.js +397 -406
  161. package/lib/web/pdf_link_service.js +304 -348
  162. package/lib/web/pdf_outline_viewer.js +140 -175
  163. package/lib/web/pdf_page_view.js +452 -523
  164. package/lib/web/pdf_presentation_mode.js +308 -357
  165. package/lib/web/pdf_print_service.js +90 -104
  166. package/lib/web/pdf_rendering_queue.js +84 -108
  167. package/lib/web/pdf_sidebar.js +276 -306
  168. package/lib/web/pdf_sidebar_resizer.js +92 -119
  169. package/lib/web/pdf_single_page_viewer.js +77 -126
  170. package/lib/web/pdf_thumbnail_view.js +276 -297
  171. package/lib/web/pdf_thumbnail_viewer.js +186 -206
  172. package/lib/web/pdf_viewer.component.js +20 -21
  173. package/lib/web/pdf_viewer.js +55 -115
  174. package/lib/web/preferences.js +82 -286
  175. package/lib/web/secondary_toolbar.js +164 -196
  176. package/lib/web/text_layer_builder.js +282 -339
  177. package/lib/web/toolbar.js +217 -210
  178. package/lib/web/ui_utils.js +267 -420
  179. package/lib/web/view_history.js +52 -226
  180. package/lib/web/viewer_compatibility.js +21 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +35 -25
  183. package/web/pdf_viewer.js +3489 -4855
  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 -494
  189. package/lib/shared/streams_polyfill.js +0 -43
  190. package/lib/shared/url_polyfill.js +0 -56
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -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.
@@ -21,21 +21,21 @@
21
21
  */
22
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 () {
26
+ describe("bidi", function () {
27
+ it("should mark text as RTL if more than 30% of text is RTL", function () {
28
28
  var test = "\u0645\u0635\u0631 Egypt";
29
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 () {
34
+ it("should mark text as LTR if less than 30% of text is RTL", function () {
35
35
  var test = "Egypt is known as \u0645\u0635\u0631 in Arabic.";
36
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.
@@ -21,13 +21,13 @@
21
21
  */
22
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
 
@@ -39,13 +39,14 @@ describe('CFFParser', function () {
39
39
  }
40
40
 
41
41
  var privateDictStub = {
42
- getByName: function getByName(name) {
42
+ getByName(name) {
43
43
  return 0;
44
44
  }
45
+
45
46
  };
46
47
  var fontData, parser, cff;
47
48
  beforeAll(function (done) {
48
- 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";
49
50
  var fontArr = [];
50
51
 
51
52
  for (var i = 0, ii = exampleFont.length; i < ii; i += 2) {
@@ -68,56 +69,56 @@ describe('CFFParser', function () {
68
69
  parser = cff = null;
69
70
  done();
70
71
  });
71
- it('parses header', function () {
72
+ it("parses header", function () {
72
73
  var header = cff.header;
73
74
  expect(header.major).toEqual(1);
74
75
  expect(header.minor).toEqual(0);
75
76
  expect(header.hdrSize).toEqual(4);
76
77
  expect(header.offSize).toEqual(1);
77
78
  });
78
- it('parses name index', function () {
79
+ it("parses name index", function () {
79
80
  var names = cff.names;
80
81
  expect(names.length).toEqual(1);
81
- expect(names[0]).toEqual('ABCDEF+Times-Roman');
82
+ expect(names[0]).toEqual("ABCDEF+Times-Roman");
82
83
  });
83
- it('parses string index', function () {
84
+ it("parses string index", function () {
84
85
  var strings = cff.strings;
85
86
  expect(strings.count).toEqual(3);
86
- expect(strings.get(0)).toEqual('.notdef');
87
- expect(strings.get(391)).toEqual('001.007');
87
+ expect(strings.get(0)).toEqual(".notdef");
88
+ expect(strings.get(391)).toEqual("001.007");
88
89
  });
89
- it('parses top dict', function () {
90
+ it("parses top dict", function () {
90
91
  var topDict = cff.topDict;
91
- expect(topDict.getByName('version')).toEqual(391);
92
- expect(topDict.getByName('FullName')).toEqual(392);
93
- expect(topDict.getByName('FamilyName')).toEqual(393);
94
- expect(topDict.getByName('Weight')).toEqual(389);
95
- expect(topDict.getByName('UniqueID')).toEqual(28416);
96
- expect(topDict.getByName('FontBBox')).toEqual([-168, -218, 1000, 898]);
97
- expect(topDict.getByName('CharStrings')).toEqual(94);
98
- 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]);
99
100
  });
100
- 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 () {
101
102
  var topDict = cff.topDict;
102
- var defaultValue = topDict.getByName('UnderlinePosition');
103
+ var defaultValue = topDict.getByName("UnderlinePosition");
103
104
  topDict.setByKey(3075, [NaN]);
104
- expect(topDict.getByName('UnderlinePosition')).toEqual(defaultValue);
105
+ expect(topDict.getByName("UnderlinePosition")).toEqual(defaultValue);
105
106
  });
106
- 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 () {
107
108
  var bytes = new Uint8Array([64, 39, 31, 30, 252, 114, 137, 115, 79, 30, 197, 119, 2, 99, 127, 6]);
108
109
  parser.bytes = bytes;
109
110
  var topDict = cff.topDict;
110
- topDict.setByName('Private', [bytes.length, 0]);
111
+ topDict.setByName("Private", [bytes.length, 0]);
111
112
 
112
- var parsePrivateDict = function parsePrivateDict() {
113
+ var parsePrivateDict = function () {
113
114
  parser.parsePrivateDict(topDict);
114
115
  };
115
116
 
116
117
  expect(parsePrivateDict).not.toThrow();
117
118
  var privateDict = topDict.privateDict;
118
- expect(privateDict.getByName('BlueValues')).toBeNull();
119
+ expect(privateDict.getByName("BlueValues")).toBeNull();
119
120
  });
120
- it('parses a CharString having cntrmask', function () {
121
+ it("parses a CharString having cntrmask", function () {
121
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]);
122
123
  parser.bytes = bytes;
123
124
  var charStringsIndex = parser.parseIndex(0).obj;
@@ -128,13 +129,13 @@ describe('CFFParser', function () {
128
129
  expect(charStrings.count).toEqual(1);
129
130
  expect(charStrings.get(0).length).toEqual(38);
130
131
  });
131
- it('parses a CharString endchar with 4 args w/seac enabled', function () {
132
- var parser = new _cff_parser.CFFParser(fontData, {}, true);
133
- parser.parse();
132
+ it("parses a CharString endchar with 4 args w/seac enabled", function () {
133
+ const cffParser = new _cff_parser.CFFParser(fontData, {}, true);
134
+ cffParser.parse();
134
135
  var bytes = new Uint8Array([0, 1, 1, 0, 237, 247, 22, 247, 72, 204, 247, 86, 14]);
135
- parser.bytes = bytes;
136
- var charStringsIndex = parser.parseIndex(0).obj;
137
- var result = parser.parseCharStrings({
136
+ cffParser.bytes = bytes;
137
+ var charStringsIndex = cffParser.parseIndex(0).obj;
138
+ var result = cffParser.parseCharStrings({
138
139
  charStrings: charStringsIndex,
139
140
  privateDict: privateDictStub
140
141
  });
@@ -147,13 +148,13 @@ describe('CFFParser', function () {
147
148
  expect(result.seacs[0][2]).toEqual(65);
148
149
  expect(result.seacs[0][3]).toEqual(194);
149
150
  });
150
- it('parses a CharString endchar with 4 args w/seac disabled', function () {
151
- var parser = new _cff_parser.CFFParser(fontData, {}, false);
152
- parser.parse();
151
+ it("parses a CharString endchar with 4 args w/seac disabled", function () {
152
+ const cffParser = new _cff_parser.CFFParser(fontData, {}, false);
153
+ cffParser.parse();
153
154
  var bytes = new Uint8Array([0, 1, 1, 0, 237, 247, 22, 247, 72, 204, 247, 86, 14]);
154
- parser.bytes = bytes;
155
- var charStringsIndex = parser.parseIndex(0).obj;
156
- var result = parser.parseCharStrings({
155
+ cffParser.bytes = bytes;
156
+ var charStringsIndex = cffParser.parseIndex(0).obj;
157
+ var result = cffParser.parseCharStrings({
157
158
  charStrings: charStringsIndex,
158
159
  privateDict: privateDictStub
159
160
  });
@@ -161,7 +162,7 @@ describe('CFFParser', function () {
161
162
  expect(result.charStrings.get(0).length).toEqual(9);
162
163
  expect(result.seacs.length).toEqual(0);
163
164
  });
164
- it('parses a CharString endchar no args', function () {
165
+ it("parses a CharString endchar no args", function () {
165
166
  var bytes = new Uint8Array([0, 1, 1, 0, 14]);
166
167
  parser.bytes = bytes;
167
168
  var charStringsIndex = parser.parseIndex(0).obj;
@@ -173,35 +174,35 @@ describe('CFFParser', function () {
173
174
  expect(result.charStrings.get(0)[0]).toEqual(14);
174
175
  expect(result.seacs.length).toEqual(0);
175
176
  });
176
- it('parses predefined charsets', function () {
177
+ it("parses predefined charsets", function () {
177
178
  var charset = parser.parseCharsets(0, 0, null, true);
178
179
  expect(charset.predefined).toEqual(true);
179
180
  });
180
- it('parses charset format 0', function () {
181
+ it("parses charset format 0", function () {
181
182
  var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x00, 0x00, 0x02]);
182
183
  parser.bytes = bytes;
183
184
  var charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), false);
184
- expect(charset.charset[1]).toEqual('exclam');
185
+ expect(charset.charset[1]).toEqual("exclam");
185
186
  charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), true);
186
187
  expect(charset.charset[1]).toEqual(2);
187
188
  });
188
- it('parses charset format 1', function () {
189
+ it("parses charset format 1", function () {
189
190
  var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x01]);
190
191
  parser.bytes = bytes;
191
192
  var charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), false);
192
- expect(charset.charset).toEqual(['.notdef', 'quoteright', 'parenleft']);
193
+ expect(charset.charset).toEqual([".notdef", "quoteright", "parenleft"]);
193
194
  charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), true);
194
- expect(charset.charset).toEqual(['.notdef', 8, 9]);
195
+ expect(charset.charset).toEqual([0, 8, 9]);
195
196
  });
196
- it('parses charset format 2', function () {
197
+ it("parses charset format 2", function () {
197
198
  var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x01]);
198
199
  parser.bytes = bytes;
199
200
  var charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), false);
200
- expect(charset.charset).toEqual(['.notdef', 'quoteright', 'parenleft']);
201
+ expect(charset.charset).toEqual([".notdef", "quoteright", "parenleft"]);
201
202
  charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), true);
202
- expect(charset.charset).toEqual(['.notdef', 8, 9]);
203
+ expect(charset.charset).toEqual([0, 8, 9]);
203
204
  });
204
- it('parses encoding format 0', function () {
205
+ it("parses encoding format 0", function () {
205
206
  var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x01, 0x08]);
206
207
  parser.bytes = bytes;
207
208
  var encoding = parser.parseEncoding(2, {}, new _cff_parser.CFFStrings(), null);
@@ -209,7 +210,7 @@ describe('CFFParser', function () {
209
210
  0x8: 1
210
211
  }));
211
212
  });
212
- it('parses encoding format 1', function () {
213
+ it("parses encoding format 1", function () {
213
214
  var bytes = new Uint8Array([0x00, 0x00, 0x01, 0x01, 0x07, 0x01]);
214
215
  parser.bytes = bytes;
215
216
  var encoding = parser.parseEncoding(2, {}, new _cff_parser.CFFStrings(), null);
@@ -218,21 +219,21 @@ describe('CFFParser', function () {
218
219
  0x08: 0x02
219
220
  }));
220
221
  });
221
- it('parses fdselect format 0', function () {
222
+ it("parses fdselect format 0", function () {
222
223
  var bytes = new Uint8Array([0x00, 0x00, 0x01]);
223
224
  parser.bytes = bytes.slice();
224
225
  var fdSelect = parser.parseFDSelect(0, 2);
225
226
  expect(fdSelect.fdSelect).toEqual([0, 1]);
226
227
  expect(fdSelect.format).toEqual(0);
227
228
  });
228
- it('parses fdselect format 3', function () {
229
+ it("parses fdselect format 3", function () {
229
230
  var bytes = new Uint8Array([0x03, 0x00, 0x02, 0x00, 0x00, 0x09, 0x00, 0x02, 0x0a, 0x00, 0x04]);
230
231
  parser.bytes = bytes.slice();
231
232
  var fdSelect = parser.parseFDSelect(0, 4);
232
233
  expect(fdSelect.fdSelect).toEqual([9, 9, 0xa, 0xa]);
233
234
  expect(fdSelect.format).toEqual(3);
234
235
  });
235
- it('parses invalid fdselect format 3 (bug 1146106)', function () {
236
+ it("parses invalid fdselect format 3 (bug 1146106)", function () {
236
237
  var bytes = new Uint8Array([0x03, 0x00, 0x02, 0x00, 0x01, 0x09, 0x00, 0x02, 0x0a, 0x00, 0x04]);
237
238
  parser.bytes = bytes.slice();
238
239
  var fdSelect = parser.parseFDSelect(0, 4);
@@ -240,17 +241,17 @@ describe('CFFParser', function () {
240
241
  expect(fdSelect.format).toEqual(3);
241
242
  });
242
243
  });
243
- describe('CFFCompiler', function () {
244
+ describe("CFFCompiler", function () {
244
245
  function testParser(bytes) {
245
246
  bytes = new Uint8Array(bytes);
246
247
  return new _cff_parser.CFFParser({
247
- getBytes: function getBytes() {
248
+ getBytes: () => {
248
249
  return bytes;
249
250
  }
250
251
  }, {}, _fonts.SEAC_ANALYSIS_ENABLED);
251
252
  }
252
253
 
253
- it('encodes integers', function () {
254
+ it("encodes integers", function () {
254
255
  var c = new _cff_parser.CFFCompiler();
255
256
  expect(c.encodeInteger(0)).toEqual([0x8b]);
256
257
  expect(c.encodeInteger(100)).toEqual([0xef]);
@@ -262,22 +263,22 @@ describe('CFFCompiler', function () {
262
263
  expect(c.encodeInteger(100000)).toEqual([0x1d, 0x00, 0x01, 0x86, 0xa0]);
263
264
  expect(c.encodeInteger(-100000)).toEqual([0x1d, 0xff, 0xfe, 0x79, 0x60]);
264
265
  });
265
- it('encodes floats', function () {
266
+ it("encodes floats", function () {
266
267
  var c = new _cff_parser.CFFCompiler();
267
268
  expect(c.encodeFloat(-2.25)).toEqual([0x1e, 0xe2, 0xa2, 0x5f]);
268
269
  expect(c.encodeFloat(5e-11)).toEqual([0x1e, 0x5c, 0x11, 0xff]);
269
270
  });
270
- it('sanitizes name index', function () {
271
+ it("sanitizes name index", function () {
271
272
  var c = new _cff_parser.CFFCompiler();
272
- var nameIndexCompiled = c.compileNameIndex(['[a']);
273
+ var nameIndexCompiled = c.compileNameIndex(["[a"]);
273
274
  var parser = testParser(nameIndexCompiled);
274
275
  var nameIndex = parser.parseIndex(0);
275
276
  var names = parser.parseNameIndex(nameIndex.obj);
276
- expect(names).toEqual(['_a']);
277
- var longName = '';
277
+ expect(names).toEqual(["_a"]);
278
+ var longName = "";
278
279
 
279
280
  for (var i = 0; i < 129; i++) {
280
- longName += '_';
281
+ longName += "_";
281
282
  }
282
283
 
283
284
  nameIndexCompiled = c.compileNameIndex([longName]);
@@ -286,22 +287,36 @@ describe('CFFCompiler', function () {
286
287
  names = parser.parseNameIndex(nameIndex.obj);
287
288
  expect(names[0].length).toEqual(127);
288
289
  });
289
- it('compiles fdselect format 0', function () {
290
+ it("compiles fdselect format 0", function () {
290
291
  var fdSelect = new _cff_parser.CFFFDSelect(0, [3, 2, 1]);
291
292
  var c = new _cff_parser.CFFCompiler();
292
293
  var out = c.compileFDSelect(fdSelect);
293
294
  expect(out).toEqual([0, 3, 2, 1]);
294
295
  });
295
- it('compiles fdselect format 3', function () {
296
+ it("compiles fdselect format 3", function () {
296
297
  var fdSelect = new _cff_parser.CFFFDSelect(3, [0, 0, 1, 1]);
297
298
  var c = new _cff_parser.CFFCompiler();
298
299
  var out = c.compileFDSelect(fdSelect);
299
300
  expect(out).toEqual([3, 0, 2, 0, 0, 0, 0, 2, 1, 0, 4]);
300
301
  });
301
- it('compiles fdselect format 3, single range', function () {
302
+ it("compiles fdselect format 3, single range", function () {
302
303
  var fdSelect = new _cff_parser.CFFFDSelect(3, [0, 0]);
303
304
  var c = new _cff_parser.CFFCompiler();
304
305
  var out = c.compileFDSelect(fdSelect);
305
306
  expect(out).toEqual([3, 0, 1, 0, 0, 0, 0, 2]);
306
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
+ });
307
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.
@@ -21,18 +21,16 @@
21
21
  */
22
22
  "use strict";
23
23
 
24
- var _util = require("../../shared/util");
24
+ var _util = require("../../shared/util.js");
25
25
 
26
- var _is_node = _interopRequireDefault(require("../../shared/is_node"));
26
+ var _is_node = require("../../shared/is_node.js");
27
27
 
28
- var _node_stream = require("../../display/node_stream");
28
+ var _node_stream = require("../../display/node_stream.js");
29
29
 
30
- var _api = require("../../display/api");
30
+ var _api = require("../../display/api.js");
31
31
 
32
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
-
34
- if (!(0, _is_node.default)()) {
35
- 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.");
36
34
  }
37
35
 
38
36
  (0, _util.setVerbosityLevel)(_util.VerbosityLevel.ERRORS);