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.
- package/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +25500 -26628
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +2887 -4094
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- 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
|
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
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
|
-
var _bidi = require(
|
24
|
+
var _bidi = require("../../core/bidi.js");
|
25
25
|
|
26
|
-
describe(
|
27
|
-
it(
|
28
|
-
var test =
|
29
|
-
var result =
|
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(
|
32
|
+
expect(bidiText.dir).toEqual("rtl");
|
33
33
|
});
|
34
|
-
it(
|
35
|
-
var test =
|
36
|
-
var result =
|
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(
|
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
|
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
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
|
-
var _cff_parser = require(
|
24
|
+
var _cff_parser = require("../../core/cff_parser.js");
|
25
25
|
|
26
|
-
var _fonts = require(
|
26
|
+
var _fonts = require("../../core/fonts.js");
|
27
27
|
|
28
|
-
var _stream = require(
|
28
|
+
var _stream = require("../../core/stream.js");
|
29
29
|
|
30
|
-
describe(
|
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
|
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 =
|
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(
|
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(
|
79
|
+
it("parses name index", function () {
|
74
80
|
var names = cff.names;
|
75
81
|
expect(names.length).toEqual(1);
|
76
|
-
expect(names[0]).toEqual(
|
82
|
+
expect(names[0]).toEqual("ABCDEF+Times-Roman");
|
77
83
|
});
|
78
|
-
it(
|
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(
|
82
|
-
expect(strings.get(391)).toEqual(
|
87
|
+
expect(strings.get(0)).toEqual(".notdef");
|
88
|
+
expect(strings.get(391)).toEqual("001.007");
|
83
89
|
});
|
84
|
-
it(
|
90
|
+
it("parses top dict", function () {
|
85
91
|
var topDict = cff.topDict;
|
86
|
-
expect(topDict.getByName(
|
87
|
-
expect(topDict.getByName(
|
88
|
-
expect(topDict.getByName(
|
89
|
-
expect(topDict.getByName(
|
90
|
-
expect(topDict.getByName(
|
91
|
-
expect(topDict.getByName(
|
92
|
-
expect(topDict.getByName(
|
93
|
-
expect(topDict.getByName(
|
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(
|
101
|
+
it("refuses to add topDict key with invalid value (bug 1068432)", function () {
|
96
102
|
var topDict = cff.topDict;
|
97
|
-
var defaultValue = topDict.getByName(
|
103
|
+
var defaultValue = topDict.getByName("UnderlinePosition");
|
98
104
|
topDict.setByKey(3075, [NaN]);
|
99
|
-
expect(topDict.getByName(
|
105
|
+
expect(topDict.getByName("UnderlinePosition")).toEqual(defaultValue);
|
100
106
|
});
|
101
|
-
it(
|
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(
|
106
|
-
|
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(
|
119
|
+
expect(privateDict.getByName("BlueValues")).toBeNull();
|
112
120
|
});
|
113
|
-
it(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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([
|
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([
|
195
|
+
expect(charset.charset).toEqual([".notdef", 8, 9]);
|
188
196
|
});
|
189
|
-
it(
|
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([
|
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([
|
203
|
+
expect(charset.charset).toEqual([".notdef", 8, 9]);
|
196
204
|
});
|
197
|
-
it(
|
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({
|
209
|
+
expect(encoding.encoding).toEqual(createWithNullProto({
|
210
|
+
0x8: 1
|
211
|
+
}));
|
202
212
|
});
|
203
|
-
it(
|
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(
|
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(
|
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(
|
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(
|
244
|
+
describe("CFFCompiler", function () {
|
235
245
|
function testParser(bytes) {
|
236
246
|
bytes = new Uint8Array(bytes);
|
237
247
|
return new _cff_parser.CFFParser({
|
238
|
-
getBytes:
|
248
|
+
getBytes: () => {
|
239
249
|
return bytes;
|
240
250
|
}
|
241
251
|
}, {}, _fonts.SEAC_ANALYSIS_ENABLED);
|
242
252
|
}
|
243
|
-
|
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(
|
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(
|
271
|
+
it("sanitizes name index", function () {
|
261
272
|
var c = new _cff_parser.CFFCompiler();
|
262
|
-
var nameIndexCompiled = c.compileNameIndex([
|
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([
|
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(
|
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(
|
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(
|
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
|
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
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
|
-
var _util = require(
|
24
|
+
var _util = require("../../shared/util.js");
|
25
25
|
|
26
|
-
var _is_node = require(
|
26
|
+
var _is_node = require("../../shared/is_node.js");
|
27
27
|
|
28
|
-
var
|
28
|
+
var _node_stream = require("../../display/node_stream.js");
|
29
29
|
|
30
|
-
var
|
30
|
+
var _api = require("../../display/api.js");
|
31
31
|
|
32
|
-
|
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);
|