pdfjs-dist 2.2.228 → 2.6.347
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/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8816 -19300
- 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 +27185 -35746
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +26665 -0
- package/es5/build/pdf.js.map +1 -0
- package/es5/build/pdf.min.js +22 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +61231 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -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/pdf_viewer.css +406 -0
- package/es5/web/pdf_viewer.js +7886 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1498 -4832
- 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 +1144 -927
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +747 -716
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +462 -553
- package/lib/core/cmap.js +231 -277
- package/lib/core/colorspace.js +715 -857
- package/lib/core/core_utils.js +57 -52
- package/lib/core/crypto.js +416 -437
- package/lib/core/document.js +629 -670
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +3229 -2800
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +602 -534
- package/lib/core/function.js +355 -279
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +442 -439
- package/lib/core/image_utils.js +221 -61
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +289 -233
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2928 -2928
- package/lib/core/murmurhash3.js +87 -102
- package/lib/core/obj.js +1343 -1300
- package/lib/core/operator_list.js +90 -67
- package/lib/core/parser.js +990 -987
- package/lib/core/pattern.js +105 -77
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +156 -104
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +89 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +275 -290
- package/lib/core/worker_stream.js +101 -210
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +772 -1041
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +1575 -1868
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +370 -222
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +341 -536
- package/lib/display/fetch_stream.js +188 -304
- package/lib/display/font_loader.js +282 -414
- package/lib/display/metadata.js +81 -99
- package/lib/display/network.js +362 -511
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +283 -465
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/pattern_helper.js +93 -44
- package/lib/display/svg.js +1163 -1401
- package/lib/display/text_layer.js +154 -137
- package/lib/display/transport_stream.js +237 -375
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +37 -37
- package/lib/pdf.js +220 -58
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +271 -306
- package/lib/test/unit/annotation_spec.js +1902 -763
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +790 -592
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +73 -72
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +86 -88
- package/lib/test/unit/colorspace_spec.js +346 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +232 -185
- package/lib/test/unit/custom_spec.js +150 -24
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +128 -17
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +112 -91
- package/lib/test/unit/fetch_stream_spec.js +31 -29
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +48 -32
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +71 -71
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -11
- package/lib/test/unit/network_utils_spec.js +158 -144
- package/lib/test/unit/node_stream_spec.js +76 -90
- package/lib/test/unit/parser_spec.js +108 -114
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +337 -156
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +91 -304
- package/lib/test/unit/testreporter.js +33 -22
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +299 -461
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +129 -149
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +78 -111
- package/lib/web/app.js +1542 -1267
- package/lib/web/app_options.js +76 -91
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +869 -834
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +34 -58
- package/lib/web/firefox_print_service.js +62 -34
- package/lib/web/firefoxcom.js +206 -374
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +30 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +150 -126
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +229 -383
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +492 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +119 -212
- package/lib/web/pdf_page_view.js +474 -513
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +96 -110
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +286 -302
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +289 -297
- package/lib/web/pdf_thumbnail_viewer.js +202 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +69 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -319
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +274 -421
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +4 -9
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +29 -27
- package/web/pdf_viewer.js +3524 -4746
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +6 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/web/images/texture.png +0 -0
@@ -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.
|
@@ -26,33 +26,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.FontRendererFactory = void 0;
|
28
28
|
|
29
|
-
var _util = require("../shared/util");
|
29
|
+
var _util = require("../shared/util.js");
|
30
30
|
|
31
|
-
var _cff_parser = require("./cff_parser");
|
31
|
+
var _cff_parser = require("./cff_parser.js");
|
32
32
|
|
33
|
-
var _glyphlist = require("./glyphlist");
|
33
|
+
var _glyphlist = require("./glyphlist.js");
|
34
34
|
|
35
|
-
var _encodings = require("./encodings");
|
35
|
+
var _encodings = require("./encodings.js");
|
36
36
|
|
37
|
-
var _stream = require("./stream");
|
38
|
-
|
39
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
40
|
-
|
41
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
42
|
-
|
43
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
44
|
-
|
45
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
46
|
-
|
47
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
48
|
-
|
49
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
50
|
-
|
51
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
52
|
-
|
53
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
54
|
-
|
55
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
37
|
+
var _stream = require("./stream.js");
|
56
38
|
|
57
39
|
var FontRendererFactory = function FontRendererFactoryClosure() {
|
58
40
|
function getLong(data, offset) {
|
@@ -63,6 +45,19 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
63
45
|
return data[offset] << 8 | data[offset + 1];
|
64
46
|
}
|
65
47
|
|
48
|
+
function getSubroutineBias(subrs) {
|
49
|
+
const numSubrs = subrs.length;
|
50
|
+
let bias = 32768;
|
51
|
+
|
52
|
+
if (numSubrs < 1240) {
|
53
|
+
bias = 107;
|
54
|
+
} else if (numSubrs < 33900) {
|
55
|
+
bias = 1131;
|
56
|
+
}
|
57
|
+
|
58
|
+
return bias;
|
59
|
+
}
|
60
|
+
|
66
61
|
function parseCmap(data, start, end) {
|
67
62
|
var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
|
68
63
|
var format = getUshort(data, start + offset);
|
@@ -124,7 +119,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
124
119
|
return ranges;
|
125
120
|
}
|
126
121
|
|
127
|
-
throw new _util.FormatError(
|
122
|
+
throw new _util.FormatError(`unsupported cmap: ${format}`);
|
128
123
|
}
|
129
124
|
|
130
125
|
function parseCff(data, start, end, seacAnalysisEnabled) {
|
@@ -187,7 +182,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
187
182
|
}
|
188
183
|
|
189
184
|
if (ranges[l].start <= code && code <= ranges[l].end) {
|
190
|
-
gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) &
|
185
|
+
gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xffff;
|
191
186
|
}
|
192
187
|
|
193
188
|
return {
|
@@ -199,21 +194,21 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
199
194
|
function compileGlyf(code, cmds, font) {
|
200
195
|
function moveTo(x, y) {
|
201
196
|
cmds.push({
|
202
|
-
cmd:
|
197
|
+
cmd: "moveTo",
|
203
198
|
args: [x, y]
|
204
199
|
});
|
205
200
|
}
|
206
201
|
|
207
202
|
function lineTo(x, y) {
|
208
203
|
cmds.push({
|
209
|
-
cmd:
|
204
|
+
cmd: "lineTo",
|
210
205
|
args: [x, y]
|
211
206
|
});
|
212
207
|
}
|
213
208
|
|
214
209
|
function quadraticCurveTo(xa, ya, x, y) {
|
215
210
|
cmds.push({
|
216
|
-
cmd:
|
211
|
+
cmd: "quadraticCurveTo",
|
217
212
|
args: [xa, ya, x, y]
|
218
213
|
});
|
219
214
|
}
|
@@ -273,15 +268,15 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
273
268
|
|
274
269
|
if (subglyph) {
|
275
270
|
cmds.push({
|
276
|
-
cmd:
|
271
|
+
cmd: "save"
|
277
272
|
});
|
278
273
|
cmds.push({
|
279
|
-
cmd:
|
274
|
+
cmd: "transform",
|
280
275
|
args: [scaleX, scale01, scale10, scaleY, x, y]
|
281
276
|
});
|
282
277
|
compileGlyf(subglyph, cmds, font);
|
283
278
|
cmds.push({
|
284
|
-
cmd:
|
279
|
+
cmd: "restore"
|
285
280
|
});
|
286
281
|
}
|
287
282
|
} while (flags & 0x20);
|
@@ -309,7 +304,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
309
304
|
|
310
305
|
while (repeat-- > 0) {
|
311
306
|
points.push({
|
312
|
-
flags
|
307
|
+
flags
|
313
308
|
});
|
314
309
|
}
|
315
310
|
}
|
@@ -390,33 +385,33 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
390
385
|
}
|
391
386
|
}
|
392
387
|
|
393
|
-
function compileCharString(
|
394
|
-
var stack = [];
|
395
|
-
var x = 0,
|
396
|
-
y = 0;
|
397
|
-
var stems = 0;
|
398
|
-
|
388
|
+
function compileCharString(charStringCode, cmds, font, glyphId) {
|
399
389
|
function moveTo(x, y) {
|
400
390
|
cmds.push({
|
401
|
-
cmd:
|
391
|
+
cmd: "moveTo",
|
402
392
|
args: [x, y]
|
403
393
|
});
|
404
394
|
}
|
405
395
|
|
406
396
|
function lineTo(x, y) {
|
407
397
|
cmds.push({
|
408
|
-
cmd:
|
398
|
+
cmd: "lineTo",
|
409
399
|
args: [x, y]
|
410
400
|
});
|
411
401
|
}
|
412
402
|
|
413
403
|
function bezierCurveTo(x1, y1, x2, y2, x, y) {
|
414
404
|
cmds.push({
|
415
|
-
cmd:
|
405
|
+
cmd: "bezierCurveTo",
|
416
406
|
args: [x1, y1, x2, y2, x, y]
|
417
407
|
});
|
418
408
|
}
|
419
409
|
|
410
|
+
var stack = [];
|
411
|
+
var x = 0,
|
412
|
+
y = 0;
|
413
|
+
var stems = 0;
|
414
|
+
|
420
415
|
function parse(code) {
|
421
416
|
var i = 0;
|
422
417
|
|
@@ -499,23 +494,22 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
499
494
|
subrCode = null;
|
500
495
|
|
501
496
|
if (font.isCFFCIDFont) {
|
502
|
-
|
497
|
+
const fdIndex = font.fdSelect.getFDIndex(glyphId);
|
503
498
|
|
504
499
|
if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
|
505
|
-
|
506
|
-
|
500
|
+
const fontDict = font.fdArray[fdIndex];
|
501
|
+
let subrs;
|
507
502
|
|
508
503
|
if (fontDict.privateDict && fontDict.privateDict.subrsIndex) {
|
509
504
|
subrs = fontDict.privateDict.subrsIndex.objects;
|
510
505
|
}
|
511
506
|
|
512
507
|
if (subrs) {
|
513
|
-
|
514
|
-
n += numSubrs < 1240 ? 107 : numSubrs < 33900 ? 1131 : 32768;
|
508
|
+
n += getSubroutineBias(subrs);
|
515
509
|
subrCode = subrs[n];
|
516
510
|
}
|
517
511
|
} else {
|
518
|
-
(0, _util.warn)(
|
512
|
+
(0, _util.warn)("Invalid fd index for glyph index.");
|
519
513
|
}
|
520
514
|
} else {
|
521
515
|
subrCode = font.subrs[n + font.subrsBias];
|
@@ -605,7 +599,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
605
599
|
break;
|
606
600
|
|
607
601
|
default:
|
608
|
-
throw new _util.FormatError(
|
602
|
+
throw new _util.FormatError(`unknown operator: 12 ${v}`);
|
609
603
|
}
|
610
604
|
|
611
605
|
break;
|
@@ -617,16 +611,16 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
617
611
|
y = stack.pop();
|
618
612
|
x = stack.pop();
|
619
613
|
cmds.push({
|
620
|
-
cmd:
|
614
|
+
cmd: "save"
|
621
615
|
});
|
622
616
|
cmds.push({
|
623
|
-
cmd:
|
617
|
+
cmd: "translate",
|
624
618
|
args: [x, y]
|
625
619
|
});
|
626
620
|
var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
|
627
621
|
compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
|
628
622
|
cmds.push({
|
629
|
-
cmd:
|
623
|
+
cmd: "restore"
|
630
624
|
});
|
631
625
|
cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[bchar]]));
|
632
626
|
compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
|
@@ -802,7 +796,7 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
802
796
|
|
803
797
|
default:
|
804
798
|
if (v < 32) {
|
805
|
-
throw new _util.FormatError(
|
799
|
+
throw new _util.FormatError(`unknown operator: ${v}`);
|
806
800
|
}
|
807
801
|
|
808
802
|
if (v < 247) {
|
@@ -825,19 +819,15 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
825
819
|
}
|
826
820
|
}
|
827
821
|
|
828
|
-
parse(
|
822
|
+
parse(charStringCode);
|
829
823
|
}
|
830
824
|
|
831
|
-
|
832
|
-
|
833
|
-
var CompiledFont =
|
834
|
-
/*#__PURE__*/
|
835
|
-
function () {
|
836
|
-
function CompiledFont(fontMatrix) {
|
837
|
-
_classCallCheck(this, CompiledFont);
|
825
|
+
const NOOP = [];
|
838
826
|
|
827
|
+
class CompiledFont {
|
828
|
+
constructor(fontMatrix) {
|
839
829
|
if (this.constructor === CompiledFont) {
|
840
|
-
(0, _util.unreachable)(
|
830
|
+
(0, _util.unreachable)("Cannot initialize CompiledFont.");
|
841
831
|
}
|
842
832
|
|
843
833
|
this.fontMatrix = fontMatrix;
|
@@ -845,136 +835,103 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
845
835
|
this.compiledCharCodeToGlyphId = Object.create(null);
|
846
836
|
}
|
847
837
|
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
var cmap = lookupCmap(this.cmap, unicode);
|
852
|
-
var fn = this.compiledGlyphs[cmap.glyphId];
|
838
|
+
getPathJs(unicode) {
|
839
|
+
const cmap = lookupCmap(this.cmap, unicode);
|
840
|
+
let fn = this.compiledGlyphs[cmap.glyphId];
|
853
841
|
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
842
|
+
if (!fn) {
|
843
|
+
fn = this.compileGlyph(this.glyphs[cmap.glyphId], cmap.glyphId);
|
844
|
+
this.compiledGlyphs[cmap.glyphId] = fn;
|
845
|
+
}
|
858
846
|
|
859
|
-
|
860
|
-
|
861
|
-
|
847
|
+
if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
|
848
|
+
this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
|
849
|
+
}
|
850
|
+
|
851
|
+
return fn;
|
852
|
+
}
|
862
853
|
|
863
|
-
|
854
|
+
compileGlyph(code, glyphId) {
|
855
|
+
if (!code || code.length === 0 || code[0] === 14) {
|
856
|
+
return NOOP;
|
864
857
|
}
|
865
|
-
}, {
|
866
|
-
key: "compileGlyph",
|
867
|
-
value: function compileGlyph(code, glyphId) {
|
868
|
-
if (!code || code.length === 0 || code[0] === 14) {
|
869
|
-
return NOOP;
|
870
|
-
}
|
871
858
|
|
872
|
-
|
859
|
+
let fontMatrix = this.fontMatrix;
|
873
860
|
|
874
|
-
|
875
|
-
|
861
|
+
if (this.isCFFCIDFont) {
|
862
|
+
const fdIndex = this.fdSelect.getFDIndex(glyphId);
|
876
863
|
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
}
|
864
|
+
if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
|
865
|
+
const fontDict = this.fdArray[fdIndex];
|
866
|
+
fontMatrix = fontDict.getByName("FontMatrix") || _util.FONT_IDENTITY_MATRIX;
|
867
|
+
} else {
|
868
|
+
(0, _util.warn)("Invalid fd index for glyph index.");
|
883
869
|
}
|
884
|
-
|
885
|
-
var cmds = [];
|
886
|
-
cmds.push({
|
887
|
-
cmd: 'save'
|
888
|
-
});
|
889
|
-
cmds.push({
|
890
|
-
cmd: 'transform',
|
891
|
-
args: fontMatrix.slice()
|
892
|
-
});
|
893
|
-
cmds.push({
|
894
|
-
cmd: 'scale',
|
895
|
-
args: ['size', '-size']
|
896
|
-
});
|
897
|
-
this.compileGlyphImpl(code, cmds, glyphId);
|
898
|
-
cmds.push({
|
899
|
-
cmd: 'restore'
|
900
|
-
});
|
901
|
-
return cmds;
|
902
|
-
}
|
903
|
-
}, {
|
904
|
-
key: "compileGlyphImpl",
|
905
|
-
value: function compileGlyphImpl() {
|
906
|
-
(0, _util.unreachable)('Children classes should implement this.');
|
907
870
|
}
|
908
|
-
}, {
|
909
|
-
key: "hasBuiltPath",
|
910
|
-
value: function hasBuiltPath(unicode) {
|
911
|
-
var cmap = lookupCmap(this.cmap, unicode);
|
912
|
-
return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
|
913
|
-
}
|
914
|
-
}]);
|
915
871
|
|
916
|
-
|
917
|
-
|
872
|
+
const cmds = [];
|
873
|
+
cmds.push({
|
874
|
+
cmd: "save"
|
875
|
+
});
|
876
|
+
cmds.push({
|
877
|
+
cmd: "transform",
|
878
|
+
args: fontMatrix.slice()
|
879
|
+
});
|
880
|
+
cmds.push({
|
881
|
+
cmd: "scale",
|
882
|
+
args: ["size", "-size"]
|
883
|
+
});
|
884
|
+
this.compileGlyphImpl(code, cmds, glyphId);
|
885
|
+
cmds.push({
|
886
|
+
cmd: "restore"
|
887
|
+
});
|
888
|
+
return cmds;
|
889
|
+
}
|
918
890
|
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
_inherits(TrueTypeCompiled, _CompiledFont);
|
891
|
+
compileGlyphImpl() {
|
892
|
+
(0, _util.unreachable)("Children classes should implement this.");
|
893
|
+
}
|
923
894
|
|
924
|
-
|
925
|
-
|
895
|
+
hasBuiltPath(unicode) {
|
896
|
+
const cmap = lookupCmap(this.cmap, unicode);
|
897
|
+
return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
|
898
|
+
}
|
926
899
|
|
927
|
-
|
900
|
+
}
|
928
901
|
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
902
|
+
class TrueTypeCompiled extends CompiledFont {
|
903
|
+
constructor(glyphs, cmap, fontMatrix) {
|
904
|
+
super(fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]);
|
905
|
+
this.glyphs = glyphs;
|
906
|
+
this.cmap = cmap;
|
933
907
|
}
|
934
908
|
|
935
|
-
|
936
|
-
|
937
|
-
value: function compileGlyphImpl(code, cmds) {
|
938
|
-
compileGlyf(code, cmds, this);
|
939
|
-
}
|
940
|
-
}]);
|
941
|
-
|
942
|
-
return TrueTypeCompiled;
|
943
|
-
}(CompiledFont);
|
944
|
-
|
945
|
-
var Type2Compiled =
|
946
|
-
/*#__PURE__*/
|
947
|
-
function (_CompiledFont2) {
|
948
|
-
_inherits(Type2Compiled, _CompiledFont2);
|
949
|
-
|
950
|
-
function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
|
951
|
-
var _this2;
|
952
|
-
|
953
|
-
_classCallCheck(this, Type2Compiled);
|
954
|
-
|
955
|
-
_this2 = _possibleConstructorReturn(this, _getPrototypeOf(Type2Compiled).call(this, fontMatrix || [0.001, 0, 0, 0.001, 0, 0]));
|
956
|
-
_this2.glyphs = cffInfo.glyphs;
|
957
|
-
_this2.gsubrs = cffInfo.gsubrs || [];
|
958
|
-
_this2.subrs = cffInfo.subrs || [];
|
959
|
-
_this2.cmap = cmap;
|
960
|
-
_this2.glyphNameMap = glyphNameMap || (0, _glyphlist.getGlyphsUnicode)();
|
961
|
-
_this2.gsubrsBias = _this2.gsubrs.length < 1240 ? 107 : _this2.gsubrs.length < 33900 ? 1131 : 32768;
|
962
|
-
_this2.subrsBias = _this2.subrs.length < 1240 ? 107 : _this2.subrs.length < 33900 ? 1131 : 32768;
|
963
|
-
_this2.isCFFCIDFont = cffInfo.isCFFCIDFont;
|
964
|
-
_this2.fdSelect = cffInfo.fdSelect;
|
965
|
-
_this2.fdArray = cffInfo.fdArray;
|
966
|
-
return _this2;
|
909
|
+
compileGlyphImpl(code, cmds) {
|
910
|
+
compileGlyf(code, cmds, this);
|
967
911
|
}
|
968
912
|
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
913
|
+
}
|
914
|
+
|
915
|
+
class Type2Compiled extends CompiledFont {
|
916
|
+
constructor(cffInfo, cmap, fontMatrix, glyphNameMap) {
|
917
|
+
super(fontMatrix || [0.001, 0, 0, 0.001, 0, 0]);
|
918
|
+
this.glyphs = cffInfo.glyphs;
|
919
|
+
this.gsubrs = cffInfo.gsubrs || [];
|
920
|
+
this.subrs = cffInfo.subrs || [];
|
921
|
+
this.cmap = cmap;
|
922
|
+
this.glyphNameMap = glyphNameMap || (0, _glyphlist.getGlyphsUnicode)();
|
923
|
+
this.gsubrsBias = getSubroutineBias(this.gsubrs);
|
924
|
+
this.subrsBias = getSubroutineBias(this.subrs);
|
925
|
+
this.isCFFCIDFont = cffInfo.isCFFCIDFont;
|
926
|
+
this.fdSelect = cffInfo.fdSelect;
|
927
|
+
this.fdArray = cffInfo.fdArray;
|
928
|
+
}
|
975
929
|
|
976
|
-
|
977
|
-
|
930
|
+
compileGlyphImpl(code, cmds, glyphId) {
|
931
|
+
compileCharString(code, cmds, this, glyphId);
|
932
|
+
}
|
933
|
+
|
934
|
+
}
|
978
935
|
|
979
936
|
return {
|
980
937
|
create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
|
@@ -988,24 +945,24 @@ var FontRendererFactory = function FontRendererFactoryClosure() {
|
|
988
945
|
var length = getLong(data, p + 12);
|
989
946
|
|
990
947
|
switch (tag) {
|
991
|
-
case
|
948
|
+
case "cmap":
|
992
949
|
cmap = parseCmap(data, offset, offset + length);
|
993
950
|
break;
|
994
951
|
|
995
|
-
case
|
952
|
+
case "glyf":
|
996
953
|
glyf = data.subarray(offset, offset + length);
|
997
954
|
break;
|
998
955
|
|
999
|
-
case
|
956
|
+
case "loca":
|
1000
957
|
loca = data.subarray(offset, offset + length);
|
1001
958
|
break;
|
1002
959
|
|
1003
|
-
case
|
960
|
+
case "head":
|
1004
961
|
unitsPerEm = getUshort(data, offset + 18);
|
1005
962
|
indexToLocFormat = getUshort(data, offset + 50);
|
1006
963
|
break;
|
1007
964
|
|
1008
|
-
case
|
965
|
+
case "CFF ":
|
1009
966
|
cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
|
1010
967
|
break;
|
1011
968
|
}
|