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.
@@ -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("unsupported cmap: ".concat(format));
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) & 0xFFFF;
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: 'moveTo',
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: 'lineTo',
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: 'quadraticCurveTo',
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: 'save'
271
+ cmd: "save"
277
272
  });
278
273
  cmds.push({
279
- cmd: 'transform',
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: 'restore'
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: 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(code, cmds, font, glyphId) {
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: 'moveTo',
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: 'lineTo',
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: 'bezierCurveTo',
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
- var fdIndex = font.fdSelect.getFDIndex(glyphId);
497
+ const fdIndex = font.fdSelect.getFDIndex(glyphId);
503
498
 
504
499
  if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
505
- var fontDict = font.fdArray[fdIndex],
506
- subrs = void 0;
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
- var numSubrs = subrs.length;
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)('Invalid fd index for glyph index.');
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("unknown operator: 12 ".concat(v));
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: 'save'
614
+ cmd: "save"
621
615
  });
622
616
  cmds.push({
623
- cmd: 'translate',
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: 'restore'
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("unknown operator: ".concat(v));
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(code);
822
+ parse(charStringCode);
829
823
  }
830
824
 
831
- var NOOP = [];
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)('Cannot initialize CompiledFont.');
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
- _createClass(CompiledFont, [{
849
- key: "getPathJs",
850
- value: function getPathJs(unicode) {
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
- if (!fn) {
855
- fn = this.compileGlyph(this.glyphs[cmap.glyphId], cmap.glyphId);
856
- this.compiledGlyphs[cmap.glyphId] = fn;
857
- }
842
+ if (!fn) {
843
+ fn = this.compileGlyph(this.glyphs[cmap.glyphId], cmap.glyphId);
844
+ this.compiledGlyphs[cmap.glyphId] = fn;
845
+ }
858
846
 
859
- if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
860
- this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
861
- }
847
+ if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
848
+ this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
849
+ }
850
+
851
+ return fn;
852
+ }
862
853
 
863
- return fn;
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
- var fontMatrix = this.fontMatrix;
859
+ let fontMatrix = this.fontMatrix;
873
860
 
874
- if (this.isCFFCIDFont) {
875
- var fdIndex = this.fdSelect.getFDIndex(glyphId);
861
+ if (this.isCFFCIDFont) {
862
+ const fdIndex = this.fdSelect.getFDIndex(glyphId);
876
863
 
877
- if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
878
- var fontDict = this.fdArray[fdIndex];
879
- fontMatrix = fontDict.getByName('FontMatrix') || _util.FONT_IDENTITY_MATRIX;
880
- } else {
881
- (0, _util.warn)('Invalid fd index for glyph index.');
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
- return CompiledFont;
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
- var TrueTypeCompiled =
920
- /*#__PURE__*/
921
- function (_CompiledFont) {
922
- _inherits(TrueTypeCompiled, _CompiledFont);
891
+ compileGlyphImpl() {
892
+ (0, _util.unreachable)("Children classes should implement this.");
893
+ }
923
894
 
924
- function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
925
- var _this;
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
- _classCallCheck(this, TrueTypeCompiled);
900
+ }
928
901
 
929
- _this = _possibleConstructorReturn(this, _getPrototypeOf(TrueTypeCompiled).call(this, fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]));
930
- _this.glyphs = glyphs;
931
- _this.cmap = cmap;
932
- return _this;
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
- _createClass(TrueTypeCompiled, [{
936
- key: "compileGlyphImpl",
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
- _createClass(Type2Compiled, [{
970
- key: "compileGlyphImpl",
971
- value: function compileGlyphImpl(code, cmds, glyphId) {
972
- compileCharString(code, cmds, this, glyphId);
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
- return Type2Compiled;
977
- }(CompiledFont);
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 'cmap':
948
+ case "cmap":
992
949
  cmap = parseCmap(data, offset, offset + length);
993
950
  break;
994
951
 
995
- case 'glyf':
952
+ case "glyf":
996
953
  glyf = data.subarray(offset, offset + length);
997
954
  break;
998
955
 
999
- case 'loca':
956
+ case "loca":
1000
957
  loca = data.subarray(offset, offset + length);
1001
958
  break;
1002
959
 
1003
- case 'head':
960
+ case "head":
1004
961
  unitsPerEm = getUshort(data, offset + 18);
1005
962
  indexToLocFormat = getUshort(data, offset + 50);
1006
963
  break;
1007
964
 
1008
- case 'CFF ':
965
+ case "CFF ":
1009
966
  cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
1010
967
  break;
1011
968
  }